Returns a Long specifying the number of time intervals between two specified dates.
DateDiff(interval, date1, date2)
interval: sexp
date1, date2: date exp
You can use the DateDiff function to determine how many specified time intervals exist between two dates. For example, you might use DateDiff to calculate the number of days between two dates, or the number of weeks between today and the end of the year.
The interval argument can have the following values:
"yyyy" | Year |
"q" | Quarter |
"m" | Month |
"y" | Day of year |
"d" | Day |
"w" | Weekday (1 = Sunday, … , 7 = Saturday) |
"ww" | Week |
To calculate the number of days between date1 and date2, you can use either day of year ("y") or day ("d"). When interval 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.
If date1 refers to a later point in time than date2, the DateDiff function returns a negative number.
OpenW 1
Print DateDiff("ww", #12/31/1999#, Now)
// returns the number of full weeks from
// today till the date
Print DateDiff("m", #01/01/1800#, Date)
// returns the numbers of month till ...
Print DateDiff("w", #01/01/1800#, Date)
// returns then numbers of weekends
Print DateDiff("ww", #01/01/1800#, Date)
// return the numbers of full weeks
Do : Sleep : Until Win_1 Is Nothing
You can indicate a time in hours, minutes and seconds, separated by “ : “; or only with four numbers for hours and minutes (with or without the using of AM or PM). Using only 4 characters forces the GFABASIC 32 editor to automatically add “:00“ for the seconds. When using AM or PM the editor automatically converts to 24 hour mode. For instance, "#2:24#" will automatically convert to #14:24:00#, and (#2:24AM#) => (#02:24:00#).
CDate(), Date, Date$, DateAdd(), DateDiff(), DatePart(), DateSerial(), DateTime$(), DateToDmy, DateToDmyHms, DateValue(), Day(), DayNo(), DmyHmsToDate(), DmyToDate(), HmsToTime(), Hour(), IsDate(), Minute(), Month(), Now, Now$(), TimeSerial(), TimeToHms, TimeValue(), Second(), Week(), WeekDay(), Year()
{Created by Sjouke Hamstra; Last updated: 28/09/2014 by James Gaite}