House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Is this a DateDiff() bug?

  << Previous Post |  RSS |  Tree View |  Sort Oldest First |  Subscribe to this Group Next >> 

Is this a DateDiff() bug?

This is what I ended up with: Jim McAtee 06/06/2004 06:29 PM
Yeah, I wrote it to help someone out with a specific problem. Glad it Pascal Peters 06/05/2004 06:09 PM
OK.  I see that now in the documentation.  Doesn't make much Jim McAtee 06/05/2004 03:00 PM
Not a bug, look in the help: Pascal Peters 06/05/2004 04:17 AM
there are problems with dateDiff(), for certain. try dates that span Tony Weeg 06/04/2004 09:40 PM
ColdFusion 5: Jim McAtee 06/04/2004 08:54 PM

06/06/2004 06:29 PM
Author: Jim McAtee Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:33006#165604 This is what I ended up with: // // Return the number of weekdays in a date range, inclusive // of the beginning and end dates. // function Workdays(date1, date2) {   var adjust = 0;   var s = IIf(DateCompare(date1, date2) gt 0, 'date2', 'date1');   var e = IIf(DateCompare(date1, date2) gt 0, 'date1', 'date2');   var ws = DayOfWeek(s);   var we = DayOfWeek(e);   if (ws eq 1 or ws eq 7)     adjust = (7 - ws + we - 1) mod 6;   else if (we eq 6 or we eq 7)     adjust = 7 - ws;   else     adjust = ((5 - ws + we) mod 5) + 1;   return ((e - s) \ 7) * 5 + adjust; } ----- Excess quoted text cut - see Original Post for more -----
06/05/2004 06:09 PM
Author: Pascal Peters Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:33006#165601 Yeah, I wrote it to help someone out with a specific problem. Glad it can give you something to start with. Pascal ----- Excess quoted text cut - see Original Post for more -----
06/05/2004 03:00 PM
Author: Jim McAtee Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:33006#165600 OK.  I see that now in the documentation.  Doesn't make much sense to me, but I'm guessing there's some use for that behavior. I've looked at your function and it's close to what I'm looking for, but I need to modify it to make it inclusive of the end dates. ----- Excess quoted text cut - see Original Post for more -----
06/05/2004 04:17 AM
Author: Pascal Peters Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:33006#165587 Not a bug, look in the help: "w" number of weeks between the two dates "ww" number of calendar weeks (Sundays) between the two dates The result between the two would differ if you have less than 7 days with a Sunday that doesn't fall on the first date. I think posted a function to return the number of weekdays (as you define it) on this list a few days ago: function WeekdaysBetween(date1,date2){   var out = 0;   var tmp = "";   if(DateCompare(date1,date2) GT 0){     tmp = date1;     date1 = date2;     date2 = tmp;   }   if(DayOfWeek(date1) IS 1) date1 = DateAdd("d",-2,date1);   if(DayOfWeek(date1) IS 7) date1 = DateAdd("d",-1,date1);   if(DayOfWeek(date2) IS 1) date2 = DateAdd("d",+1,date2);   if(DayOfWeek(date2) IS 7) date2 = DateAdd("d",+2,date2);   out = DateDiff("d",date1,date2);   if(DayOfWeek(date2) LT DayOfWeek(date1)) out = out - 2;   out = out - (out\7)*2;   return out; } Pascal ----- Excess quoted text cut - see Original Post for more -----
06/04/2004 09:40 PM
Author: Tony Weeg Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:33006#165584 there are problems with dateDiff(), for certain. try dates that span Daylight Savings time, I thought the bug was fixed, but I kinda think that one of the patches, made it wrong again, I cant say for certain, but, most likely. ....tony Tony Weeg sr. web applications architect navtrak, inc. tony@navtrak.net 410.548.2337 www.navtrak.net Visit http://www.antiwrap.com the next time you want to send a link to a friend. ColdFusion 5: <cfoutput> <pre> DateDiff("d", "5/1/2004", "5/31/2004")  = #DateDiff("d", "5/1/2004", "5/31/2004")# DateDiff("w", "5/1/2004", "5/31/2004")  = #DateDiff("w", "5/1/2004", "5/31/2004")# DateDiff("ww", "5/1/2004", "5/31/2004") = #DateDiff("ww", "5/1/2004", "5/31/2004")# </pre> </cfoutput> Gives: DateDiff("d", "5/1/2004", "5/31/2004")  = 30 DateDiff("w", "5/1/2004", "5/31/2004")  = 4 DateDiff("ww", "5/1/2004", "5/31/2004") = 4 The docs state that "w" should return the number of "Weekdays", which I take to mean the number days between the two dates, minus days that fall on a weekend. By poking different dates into the two fields I can get the w and ww results to differ by one, but most often they're the same. Bug?
06/04/2004 08:54 PM
Author: Jim McAtee Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:33006#165583 ColdFusion 5: <cfoutput> <pre> DateDiff("d", "5/1/2004", "5/31/2004")  = #DateDiff("d", "5/1/2004", "5/31/2004")# DateDiff("w", "5/1/2004", "5/31/2004")  = #DateDiff("w", "5/1/2004", "5/31/2004")# DateDiff("ww", "5/1/2004", "5/31/2004") = #DateDiff("ww", "5/1/2004", "5/31/2004")# </pre> </cfoutput> Gives: DateDiff("d", "5/1/2004", "5/31/2004")  = 30 DateDiff("w", "5/1/2004", "5/31/2004")  = 4 DateDiff("ww", "5/1/2004", "5/31/2004") = 4 The docs state that "w" should return the number of "Weekdays", which I take to mean the number days between the two dates, minus days that fall on a weekend. By poking different dates into the two fields I can get the w and ww results to differ by one, but most often they're the same. Bug?
<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference