ODBiC Discussion Board


RE: date calculations, tom, 06-29-2005

You can use $dateDiff( )

by Roger Harris, June 29, 2005 14:48

The ODBscript function $dateDiff(date1, date2) returns the number of days between the two given dates. But note that the first date is subtracted from the second, not the other way around, so the difference will be negative if the first date is after the second date. (You can use that fact to simply compare two date, e.g. <% IF $dateDiff($date1$,$date2$) < 0 %> would be true if the first date is after the second. You can use $abs($dateDiff(...)) if you want the difference to always be positive regardless of the order.)

The dates can be in any "standard" format as long as they are in month, day, year default order, or in the order that you currently have set with the SETOPTION date="..." statement (e.g. SETOPTION date="dmy" to specify European standard day, month, year order). The fields in the date can be separated by any combination of "/", "-", ".", spaces, or commas. Month names can be spelled out or abbreviated to three characters. Years can be two digits if they are in the range of 1970 to 2069. One special format exists regardless of the current SETOPTION date: any 8-digit number, such as 20050629, is assumed to be 4-digit year, 2-digit month, and 2-digit day.



Replies:


Post Your Reply:

Name   
E-mail  optional
Topic  
Message:

HTTP Link: 
Link text: 

          


Copyright ©1997-2003, Roger Harris. All rights reserved.