diffdays

Terry Vogelaar terry at discovery.nl
Tue Jul 16 23:57:01 EDT 2002


> Can someone help me to write a function that returns the difference
> of days between two dates ?
> Please don't forget the dateformat can be different from a system to
> another (U.S,French,German,...)

Hello Yves,

I don't know if this is the smartest way, but this should do it:

on mouseUp
  put "dinsdag, 9 juli 2002" into DateA
  convert DateA from system long date to seconds
  put "7/17/02" into DateB
  convert DateB from short date to seconds
  put DateA - DateB into diff
  divide diff by 86400 -- No of seconds in 1 day
  if char 1 of diff = "-" then delete char 1 of diff
  put diff
end mouseUp

and the message box shows the date of 10 days ago in French (or Dutch, or
whatever language you are using). As long as RR can understand the date
format provided, and you specify which format it is, there shouldn't be a
problem. The only thing is if the data provided is in languages other then
the system language of the user and English, in other words: on my system, I
can only interpret Dutch or English dates; not Frech or German. Maybe a nice
feature request to add a few more languages than English...

Terry





More information about the use-livecode mailing list