Is it possible to add -/+ to Switch date variable?
I want to compare to my tomorrow date, and not the present that is stated.
Ive tried:
[Switch.date]+1d
[Switch.date]+86400000
Including format and timezone it should look like this (but then also adding 1 day if possible)
[Switch.Date:Format="yyyy-MM-dd hh:mm",TimeZone=System]
The incoming xml have the date entered like this "201406191600", using the metadata and "date" doesn't work and gives me no value, if I change the date in the xml to "2014-06-18T16:20:38.483" it works...
Is it possible to change this in switch or to scheme it to work? I really would like to do this without scripting (if possible) and now change the xml (it comes from third part).
Add +1 day to [Switch.date]?
Add +1 day to [Switch.date]?
There are three things you have to combine and experiment with, but it can be done without scripting.
First, when using Switch-Date use the Format field to get the date in the form you need: yyyyMMdd will give you 20140619 instead of the full date and time (look at the tooltip!).
Second, use Switch-Calculation to add 1 to this number.
Third, you will have to put the recalculated date and the not recalculated time (Format: hhmm) together when comparing with the XML value.
I have not worked it out completely, but I am sure these hints can lead to a solution.
Freddy
First, when using Switch-Date use the Format field to get the date in the form you need: yyyyMMdd will give you 20140619 instead of the full date and time (look at the tooltip!).
Second, use Switch-Calculation to add 1 to this number.
Third, you will have to put the recalculated date and the not recalculated time (Format: hhmm) together when comparing with the XML value.
I have not worked it out completely, but I am sure these hints can lead to a solution.
Freddy
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Add +1 day to [Switch.date]?
First, when using Switch-Date use the Format field to get the date in the form you need: yyyyMMdd will give you 20140619 instead of the full date and time (look at the tooltip!).
Second, use Switch-Calculation to add 1 to this number.
This will fail for the last day of a month or year
Second, use Switch-Calculation to add 1 to this number.
This will fail for the last day of a month or year
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Add +1 day to [Switch.date]?
So are you using [Switch.date] variable or a date read from an XML file?
Add +1 day to [Switch.date]?
Correct. Checking this on connections to make different calculations depending on the day and month is technically possible, but it is going to create a nice spaghetti flow. This calls for a script expression.
Freddy
Freddy
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Add +1 day to [Switch.date]?
const milliSecsInDay = 86400000;
var tmwMilliSecs = new Date().getTime() + milliSecsInDay;
var tmw = new Date(tmwMilliSecs);
tmw.toString();
var tmwMilliSecs = new Date().getTime() + milliSecsInDay;
var tmw = new Date(tmwMilliSecs);
tmw.toString();
-
- Newbie
- Posts: 18
- Joined: Mon May 26, 2014 3:50 pm
Add +1 day to [Switch.date]?
@dkelly Im reading from an xml file. So the "format" doesnt do anything with the input, only the output. Changing the date to the common "8601" makes the date work. I was hoping to be able to NOT change the date asking third part company to change their files.
The code putted in here above, should that then be used in the "define condition", comparing that to the metadata "date"?
The code putted in here above, should that then be used in the "define condition", comparing that to the metadata "date"?
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Add +1 day to [Switch.date]?
That code is a script expression and outputs the current date/time + 24 hours. You can use it in a comparison