Here's an excerpt direct from ColdFusion Studio's help pages ;)

When datepart is Weekday ("w"), DateDiff returns the number of weeks between
the two dates. If date1 falls on a Monday, DateDiff counts the number of
Mondays until date2. It counts date2 but not date1. If interval is Week
("ww"), however, the DateDiff function returns the number of calendar weeks
between the two dates. It counts the number of Sundays between date1 and
date2. DateDiff counts date2 if it falls on a Sunday; but it doesn't count
date1, even if it does fall on a Sunday.

+-----------------------------------------------+
Bryan Love
  Database Analyst
  Macromedia Certified Professional
  Internet Application Developer
TeleCommunication Systems
[EMAIL PROTECTED]
+-----------------------------------------------+

"...'If there must be trouble, let it be in my day, that my child may have
peace'..."
        - Thomas Paine, The American Crisis

"Let's Roll"
        - Todd Beamer, Flight 93



-----Original Message-----
From: Lofback, Chris [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 19, 2003 1:14 PM
To: CF-Talk
Subject: DateDiff question


Platform: CF5/Win2K/IIS5

I'm seeing wierd results from DateDiff when using 'ww' (weeks) as the date
part.  Can anyone explain these results?

<CFSET d1 = "08/3/2003">
<CFSET d2 = "08/10/2003">
<CFOUTPUT>
        <P>#DateDiff('ww',d1,d2)#
        <!--- Result: 1 --->
</CFOUTPUT>

<CFSET d1 = "08/4/2003">
<CFSET d2 = "08/11/2003">
<CFOUTPUT>
        <P>#DateDiff('ww',d1,d2)#
        <!--- Result: 0 --->
</CFOUTPUT>

To me, these should both be 1 week.

<CFSET d1 = "1/1/2003">
<CFSET d2 = "1/11/2003">
<CFOUTPUT>
        <P>#DateDiff('ww',d1,d2)#
        <!--- Result: 0 --->
</CFOUTPUT>

<CFSET d1 = "1/1/2003">
<CFSET d2 = "1/12/2003">
<CFOUTPUT>
        <P>#DateDiff('ww',d1,d2)#
        <!--- Result: 1 --->
</CFOUTPUT>

I don't know *what* this means.  I thought maybe it was based on ordinal
weeks, but it doesn't seem to be.  Is this expected behavior?

Thanks,
Chris

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Get the mailserver that powers this list at 
http://www.coolfusion.com

Reply via email to