This message is either a "FYI" or a way to embarass myself.
I'm probably missing something very simple, or missing the point of
the DateDiff function, so my apologies if this turns out to be a
dumb posting.
I created a series of cfif/else statements to display a
different text message depending on how many days remain in a
survey. I used the DateDiff function. It works fine, counting down
from 10 to zero days, but then it calculates the next instance as
zero days again.
I solved my problem by switching to the DayOfYear function
and that produces the correct result, but I'm perplexed why the
DateDiff approach didn't work. Here's my DateDiff code:
<cfset CurrentYear = Year(Now())>
<cfset SVRSurveyEndDate = '4-20-#CurrentYear#'>
<cfset SVRSurveyDays = DATEDIFF('d',Now(),SVRSurveyEndDate
+ 1)>
If you change SVRSurveyEndDate one day at a time and output
the result, you will see the results as +2, +1, 0, 0, -1 etc.
I solved my problem using this next line instead of the third
line above:
<cfset SVRSurveyDays = (DayOfYear(SVRSurveyEndDate)) -
(DayOfYear(Now())) + 1>
But I don't know why the DateDiff function produces the two
zero results. I tried including hrs/min/sec in line 2 and varying
the time, but that still produced two zero results.