Page 1 of 1
Yesterday's Date? [SOLVED]
Posted: Fri Jun 16, 2017 12:27 pm
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

Re: Yesterday's Date?
Posted: Fri Jun 16, 2017 1:17 pm
by jan_suhr
There's a numerical value for a date that you can do calculations on.
Look in the documentation
Jan
Re: Yesterday's Date?
Posted: Fri Jun 16, 2017 1:38 pm
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();
Re: Yesterday's Date?
Posted: Fri Jun 16, 2017 3:16 pm
by TheCaptain
Thanks!
I presume this is to be run through the Scripting Module?
... which our company won't currently pay for 
Re: Yesterday's Date?
Posted: Fri Jun 16, 2017 3:32 pm
by gabrielp
TheCaptain wrote:... which our company won't currently pay for 
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 :/
Re: Yesterday's Date?
Posted: Fri Jun 16, 2017 3:39 pm
by TheCaptain
It's a running theme now Gabriel!
Company says 'Could you create XYZ'
Me 'Certainly, I just need the right equipment'
Company
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.
Re: Yesterday's Date?
Posted: Fri Jun 16, 2017 5:58 pm
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
Re: Yesterday's Date?
Posted: Fri Jun 16, 2017 5:59 pm
by jan_suhr
But it can be done with an App

Gabriel, you or me??
Then you don't need the Scripting module.
Jan
Re: Yesterday's Date?
Posted: Fri Jun 16, 2017 6:11 pm
by gabrielp
jan_suhr wrote:But it can be done with an App

Gabriel, you or me??
All you, buddy!
Re: Yesterday's Date?
Posted: Sun Jun 18, 2017 2:08 pm
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 (3.13 KiB) Viewed 47182 times

- Date Calculator properties.jpg (23.52 KiB) Viewed 47182 times

- Private data variable.jpg (90.08 KiB) Viewed 47182 times
Jan
Re: Yesterday's Date?
Posted: Mon Jun 19, 2017 1:40 pm
by sander
Pretty cool Jan, thanks for creating such an app

Re: Yesterday's Date?
Posted: Mon Jun 19, 2017 4:13 pm
by TheCaptain
Gentlemen.
You have excelled!
Very much looking forward to this...

Re: Yesterday's Date?
Posted: Mon Jun 19, 2017 4:36 pm
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
Re: Yesterday's Date? [SOLVED]
Posted: Thu Jun 22, 2017 11:29 am
by TheCaptain
This works beautifully bud. Thanks again
