Yesterday's Date? [SOLVED]

User avatar
TheCaptain
Member
Posts: 86
Joined: Mon Jan 18, 2016 4:22 pm
Location: London

Yesterday's Date? [SOLVED]

Post by TheCaptain »

I can find today's date : (in the format I need it in)

Code: Select all

[Switch.Date:Format="yyMMdd",TimeZone="UTC"]
But does anybody know how to return yesterday's date? (At any given point in time)

I could -1 off the returned numeral but that's going to fail on the 1st of every month! I'm out of ideas :|
Last edited by TheCaptain on Thu Jun 22, 2017 11:29 am, edited 1 time in total.
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Yesterday's Date?

Post by jan_suhr »

There's a numerical value for a date that you can do calculations on.

Look in the documentation

Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: Yesterday's Date?

Post by sander »

I use this in one of my transport carrier scripts to set date + 1. I think it will point you in the right direction :)

Code: Select all

	// PostNL Express 12:00 requirement
		var day = new Date();	 // today
		day.setDate(day.getDate() + 1); // Tomorrow
		var tomorrow = day.getDate()+'-'+day.getMonth()+'-'+day.getYear();
User avatar
TheCaptain
Member
Posts: 86
Joined: Mon Jan 18, 2016 4:22 pm
Location: London

Re: Yesterday's Date?

Post by TheCaptain »

Thanks!

I presume this is to be run through the Scripting Module?

... which our company won't currently pay for :cry:
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Yesterday's Date?

Post by gabrielp »

TheCaptain wrote:... which our company won't currently pay for :cry:
Time to find a new company ;)

If you can't use scripting, you might be able to subtract some time from the unformatted date in a Switch calculation. Something like [Switch.Date] - 86400000. But then I'm not sure how to format as a date again. Sorry I can't be of more help :/
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
User avatar
TheCaptain
Member
Posts: 86
Joined: Mon Jan 18, 2016 4:22 pm
Location: London

Re: Yesterday's Date?

Post by TheCaptain »

It's a running theme now Gabriel!
Company says 'Could you create XYZ'
Me 'Certainly, I just need the right equipment'
Company :lol:
Me :| :-|
I'm not sure I can get the number back into a date as you say... I presume it's some sort of maths trickery. I'll have a play and report back if I find anything.
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Yesterday's Date?

Post by jan_suhr »

It's a long standing request to be able to use Switch.Calucaltions to calculate date and time.

As it is you are stuck with calculate the Day value but as you say at the end or beginning of a month you're stuck.


Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Yesterday's Date?

Post by jan_suhr »

But it can be done with an App :-D
Gabriel, you or me??

Then you don't need the Scripting module.



Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Yesterday's Date?

Post by gabrielp »

jan_suhr wrote:But it can be done with an App :-D
Gabriel, you or me??
All you, buddy!
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Yesterday's Date?

Post by jan_suhr »

I have now made an app that is called Date Calculator. It will hopefully be on the Enfocus Appstore at the end of the week. And it will be FREE!

You can with it add or subtract days from a given date. and it will do it correctly over a change of months.

The new date will be stored as Private data in the job, you will also get Private data for Year, Month and Day so you can play around with the dates and format for your display of the date. It will only work with dates in the format 2017-06-18.
dateCalculator-icon-200.png
dateCalculator-icon-200.png (3.13 KiB) Viewed 15939 times
Date Calculator properties.jpg
Date Calculator properties.jpg (23.52 KiB) Viewed 15939 times
Private data variable.jpg
Private data variable.jpg (90.08 KiB) Viewed 15939 times

Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: Yesterday's Date?

Post by sander »

Pretty cool Jan, thanks for creating such an app :)
User avatar
TheCaptain
Member
Posts: 86
Joined: Mon Jan 18, 2016 4:22 pm
Location: London

Re: Yesterday's Date?

Post by TheCaptain »

Gentlemen.

You have excelled!

Very much looking forward to this... :P
jan_suhr
Advanced member
Posts: 592
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Yesterday's Date?

Post by jan_suhr »

Thanks,

It wasn't much of a problem since I already had the code for it in a script I made a couple of years ago.

It was just to take a snippet that could do this and make an app of it.

That is also why it is free :-)


Jan
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
User avatar
TheCaptain
Member
Posts: 86
Joined: Mon Jan 18, 2016 4:22 pm
Location: London

Re: Yesterday's Date? [SOLVED]

Post by TheCaptain »

This works beautifully bud. Thanks again 8-)
igf65
Newbie
Posts: 2
Joined: Tue Sep 26, 2017 9:53 am

Date calculator

Post by igf65 »

Hello,
I can not set up Date Calculator.
I want to rename a file to date of day +1
Thank you in advance for your help.
Igor.
Post Reply