Filtering on current date +1

Post Reply
User avatar
Terkelsen
Advanced member
Posts: 298
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Filtering on current date +1

Post by Terkelsen »

I want to be able to move files if the date in a specific metadata-field is the date of tomorrow. I can use the variable Switch.date to move the files if the date is equal to, before, after or different from the current date, but I want to be able to move the files if the date in that field is the current date +1. Any ideas?



Kind regards

Erik Terkelsen
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Filtering on current date +1

Post by dkelly »

How about "Switch.date + 86400000" which will add 24 hours to the current date
User avatar
Terkelsen
Advanced member
Posts: 298
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Filtering on current date +1

Post by Terkelsen »

It does sound like a good idea, but how do you add the 86400000 sec. when you have a "Single line text with variables" that looks like this:



[Switch.Date:Format=yyyy-M-dd]
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Filtering on current date +1

Post by dkelly »

For example: [Job.FileCreationDate] > ([Switch.Date] + 86400000)
User avatar
Terkelsen
Advanced member
Posts: 298
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Filtering on current date +1

Post by Terkelsen »

Hmm, don't think it will work.



([Switch.Date:Format=yyyy-MM-dd]+86400000)



seems just to return this value



(2011-10-27+86400000)
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Filtering on current date +1

Post by dkelly »

My statement didn't have the ":Format" option which converts to a string. Can you send me your flow and I'll implement the logic for you?



Dwight Kelly

Apago, Inc.

dkelly@apago.com
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Filtering on current date +1

Post by dkelly »

Here's the final Javascript expression solution.



var tmwMilli = new Date().getTime() + 86400000; // now + 24hrs in milliseconds

var tmw = new Date();

tmw.setTime(tmwMilli); // now + 24hrs as Date object

var ftime = job.getVariableAsDate("[Metadata.Date:Path=xap:CreateDate]"); // retrieve XMP date

var rtn = false;

if (tmw.getYear() == ftime.getYear() &&

tmw.getMonth() == ftime.getMonth() &&

tmw.getDay() == ftime.getDay()) {

rtn = true; // return true if metadata date == now + 1 day

}

rtn;





I would like to thank CrossRoads support folks for help with an issue I encountered using getVariableAsDate().



Dwight Kelly

Apago, Inc.

dkelly@apago.com
Post Reply