Calculating Days Until


#1

Folks, I have a feeling this should be simple. I want to calculate the number of days until a date. My plan was to create a variable for each date I want to calculate to and then another variable that calculates the number of days from now until each of the dates set in those already set variables.

eg.

date1 = 'mm-dd-yyyy'
date2 = 'mm-dd-yyyy'
daysToDate1 = date1-today
daysToDate2 = date2-today

I can’t figure out how to calculate the number of days. Can anyone help?


#2

something like this?

set dU = formatDuration((future date - current date), false, ‘d’)
set dU = left(dU, (indexOf(dU, ‘d’) +1))


#3
Set variable daysToDate1 = {(date1 - $now) % 86400000}

#4

And for those who wonder why this magic number… Time is handled in miliseconds, thus 60sec X 60 min X 24 hours X 1000


#5

Thank you. I will give these a try.


#6

True, true…


#7

Can someone please tell me why this evaluating to “0”?

And then…

I have the exact same thing for Christmas and that evaluates correctly. See below.

And then…

I’m stumped @Nezmo @ady624


#8

Try changing the variable names to start with a lower case like you have on the working ones. I’m not certain that’s it but I’ve not seen variables with a first char as uppercase.


#9

have you saved and run the piston once after adding those variables?


#10

Good point.

I didn’t think my point about the case was valid after thinking about it more.