f$DateAdd (f$DatumAddieren)
f$DateAdd (f$DatumAddieren)
Add a number of hours, minutes, seconds, days, weeks, months or years to a given date. The result is also a date in the form of a string. If desired, you can control the format of this date. For country-specific date formats (e.g. month display in text), country information (English, German) must be added additionally. If no format is specified, the date appears as DD.MM.YYYY (e.g. 29.02.2004).
If the entry date consists solely of a number, it is interpreted as a time. Four-digit numbers are interpreted as hours and minutes, other numbers as hours.
If the entry date is invalid, an empty string is returned.
Hint:
By adding 0 days and an appropriate format entry, this function can also be used for converting dates into another format.
Format details are to be entered as strings with fixed components and code letters beginning with %. The following code letters are possible:
%a | Abbreviated name of the day of the week (e.g. Mon) |
%A | Name of the day of the week (e.g. Monday) |
%b | Abbreviated name of the month (e.g. Jan) |
%B | Name of the month |
%c | Date with time in the country’s settings |
%d | Day of the month (01 – 31) |
%H | Hour (00 – 23) |
%j | Day of the year (001 – 366) |
%m | Month in digits (01 – 12) |
%M | Minute (00 – 59) |
%S | Second (00 – 59) |
%w | Day of the week in digits (0 – 6; Sunday is 0). As the formatting is done using a Windows function, the method of counting unfortunately cannot be changed. |
%x | Date without time in the country’s settings |
%y | Year in two digits |
%Y | Year in four digits |
%% | Percent symbol |
Syntax:
Syntax:
Date = f$DateAdd(Date,What,Number,[Format],[Region])
Argument | Type | Meaning |
|---|---|---|
Date | String | Given date |
What | String | Entry of what is to be added to the date: S - second |
Number | Integer | Number of days, weeks etc. given above (optional) |
Format | String | Format string for managing the output date (optional) |
Region | String | Entry for regional settings (e.g. English) |
Result:
String
New date created
Examples:
Date = f$DateAdd(’01.01.2004’,’d’,20)
Result: date = ’21.01.2004’
Date = f$DateAdd(’01.01.2004’,’d’,20,’ %d.%b.%Y %A ’,’German’)
Result: date = ’ 21.Jan.2004 Wednesday ’
If multiple country settings are used, the formats can be customized accordingly.
Example:
Date format = f$ReadRegValue( ’HKEY_CURRENT_USER\\Control Panel\\International\\sShortDate’ ) Dateb = f$Date( DateFormat ) |