Page 1 of 1

Filtering on current date +1

Posted: Tue Oct 25, 2011 9:35 am
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

Filtering on current date +1

Posted: Thu Oct 27, 2011 3:41 pm
by dkelly
How about "Switch.date + 86400000" which will add 24 hours to the current date

Filtering on current date +1

Posted: Thu Oct 27, 2011 3:57 pm
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]

Filtering on current date +1

Posted: Thu Oct 27, 2011 7:49 pm
by dkelly
For example: [Job.FileCreationDate] > ([Switch.Date] + 86400000)

Filtering on current date +1

Posted: Thu Oct 27, 2011 8:54 pm
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)

Filtering on current date +1

Posted: Fri Oct 28, 2011 4:03 pm
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

Filtering on current date +1

Posted: Fri Nov 04, 2011 1:22 pm
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