TheCaptain
Member
Posts: 86 Joined: Mon Jan 18, 2016 4:22 pm
Location: London
Post
by TheCaptain » Fri Jun 16, 2017 12:27 pm
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: 593 Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden
Post
by jan_suhr » Fri Jun 16, 2017 1:17 pm
There's a numerical value for a date that you can do calculations on.
Look in the documentation
Jan
sander
Advanced member
Posts: 276 Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands
Post
by sander » Fri Jun 16, 2017 1:38 pm
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();
TheCaptain
Member
Posts: 86 Joined: Mon Jan 18, 2016 4:22 pm
Location: London
Post
by TheCaptain » Fri Jun 16, 2017 3:16 pm
Thanks!
I presume this is to be run through the Scripting Module?
... which our company won't currently pay for
gabrielp
Advanced member
Posts: 645 Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:
Post
by gabrielp » Fri Jun 16, 2017 3:32 pm
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 :/
TheCaptain
Member
Posts: 86 Joined: Mon Jan 18, 2016 4:22 pm
Location: London
Post
by TheCaptain » Fri Jun 16, 2017 3:39 pm
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.
jan_suhr
Advanced member
Posts: 593 Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden
Post
by jan_suhr » Fri Jun 16, 2017 5:58 pm
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
Advanced member
Posts: 593 Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden
Post
by jan_suhr » Fri Jun 16, 2017 5:59 pm
But it can be done with an App
Gabriel, you or me??
Then you don't need the Scripting module.
Jan
gabrielp
Advanced member
Posts: 645 Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:
Post
by gabrielp » Fri Jun 16, 2017 6:11 pm
jan_suhr wrote: But it can be done with an App
Gabriel, you or me??
All you, buddy!
jan_suhr
Advanced member
Posts: 593 Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden
Post
by jan_suhr » Sun Jun 18, 2017 2:08 pm
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 15965 times
Date Calculator properties.jpg (23.52 KiB) Viewed 15965 times
Private data variable.jpg (90.08 KiB) Viewed 15965 times
Jan
sander
Advanced member
Posts: 276 Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands
Post
by sander » Mon Jun 19, 2017 1:40 pm
Pretty cool Jan, thanks for creating such an app
TheCaptain
Member
Posts: 86 Joined: Mon Jan 18, 2016 4:22 pm
Location: London
Post
by TheCaptain » Mon Jun 19, 2017 4:13 pm
Gentlemen.
You have excelled!
Very much looking forward to this...
jan_suhr
Advanced member
Posts: 593 Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden
Post
by jan_suhr » Mon Jun 19, 2017 4:36 pm
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
TheCaptain
Member
Posts: 86 Joined: Mon Jan 18, 2016 4:22 pm
Location: London
Post
by TheCaptain » Thu Jun 22, 2017 11:29 am
This works beautifully bud. Thanks again
igf65
Newbie
Posts: 2 Joined: Tue Sep 26, 2017 9:53 am
Post
by igf65 » Thu Oct 05, 2017 11:52 am
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.