[Gambas-user] DateAdd-function documentation

VBTricks.de.vu Webmaster vbtricks at ...451...
Tue Jun 1 15:59:23 CEST 2004


Well, here's a summary of the MSDN-entry for DateAdd

DateAdd returns a Date (datatype) containing a date to which a specified 
time interval has been added.

Syntax:
DateAdd(interval, number, date)

The Parameters:
Part      Description
interval  string expression that is the interval of time you want to add
number    double-datatype, number expression that is the number of
           intervals you want to add. It can be positive (to get dates in
           the future) or negative (to get dates in the past)
date      date to which the interval is added

The interval argument has these settings:

Setting Description
yyyy    Year
q       Quarter
m       Month
y       Day of year
d       Day
w       Weekday
ww      Week
h       Hour
n       Minute
s       Second


Remarks

You can use the DateAdd function to add or subtract a specified time 
interval from a date. For example, you can use DateAdd to calculate a 
date 30 days from today or a time 45 minutes from now.

To add days to date, you can use Day of Year ("y"), Day ("d"), or 
Weekday ("w").

The DateAdd function won't return an invalid date. The following example 
adds one month to January 31:

DateAdd("m", 1, "31-Jan-95")

In this case, DateAdd returns 28-Feb-95, not 31-Feb-95. If date is 
31-Jan-96, it returns 29-Feb-96 because 1996 is a leap year.

If the calculated date would precede the year 100 (that is, you subtract 
more years than are in date), an error occurs.

If number isn't a Long value, it is rounded to the nearest whole number 
before being evaluated.


Conclusion:

DateAdd is used to calculate a new date based on another date. For 
example you want to get the date of the day four weeks from today:

NewDate = DateAdd("ww", 4, Now)
'Today is June 1st, 2004 -> it'll return June 29th, 2004

Hope this helps, if you have got any additional questions, please ask!

Stefan

PS: I think interval could be a integer/long value (doesn't have to be 
double-datatype)
___________________________________________________________________________________
Schlappe uebertragungsgrenze? http://my-mail.ch/?redirect=9904
Tigra TwinTop Game! Gewinnen Sie eine Staedtereise! http://my-mail.ch/?redirect=1745





More information about the User mailing list