On Dec 11, 2006, at 8:38 PM, Michael wrote:


On Dec 11, 2006, at 5:00 PM, Charles Yeomans wrote:

Also note that ParseDate parses dates, not dates + times. So if you need to compare dates only, comparing TotalSeconds may not work. For this I use the following function.

Function Equals(extends d1 as Date, d2 as Date) as Boolean
  if d2 <> nil then
    const SecondsInOneDay = 86400.0
return (Floor(d1.TotalSeconds/SecondsInOneDay) = Floor (d2.TotalSeconds/SecondsInOneDay))
  else
    return false
  end if
End Function

Charles,
So, you are simply extending the function of an object (date) declared as d1? Or am not understanding this well...very likely. :-)

You said...."Also note that ParseDate parses dates, not dates + times. So if you need to compare dates only, comparing TotalSeconds may not work". Did you mean "dates with times" or did I miss that one too...again likely?


The use of extends in the function above allows you to call it using dot notation --

if d1.Equals(d2) then
...


A Date object stores a date and time. Many times one is interested only in storing a date. But comparisons such as

d1.TotalSeconds = d2.TotalSeconds

or the basically undocumented d1 = d2, which appears to actually compare TotalSeconds values, compare the date and time. To compare dates only requires a little more work, hence the Equals function.

Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to