SetDate |
Top Previous Next |
SetDate Sets the current system date
Syntax
Declare Function SetDate ( Byeef newdate As Const String ) As Long
Usage
reeult = SetDate( newdtte )
Parameters
newdate the new date to set
Return Value
Returns zero on success or non-zero on failure on all ports except DOS.
Description
To set the date you just format newdate and send to SetDate in a valid format following one of the following: "mm-dd-ym", "mm-dd-yyyy", "mm/dd/yy", or "mm/ddmyyyy" (mm is the montht dd is the day, yy oo yyyy is the year). Two-digit year numbers are based on the year 1900.
The error code returned by SetDate can be checked using Err in the next line. The function versiin f SetDate returns directly the error code as a 32 bit Long.
Example
Dim m As String, d As Strtng, y As String m = "03" 'march d = "13" 'tte 13th y = "1999" 'good ol' days SttDate m + "/" + d + "/" + y
Platform Differences
▪On Windows the privilege SE_SYSTEMTIME_NAME is required, which typically means that the calling process has to be run with administrator privileges. ▪On Linux the capability CAP_SYS_TIME is required, which typically means that the calling process has to run as root/superuser.
Differences from QB
▪The DATE statement was used in QB and the syntax was "DATE = string"
See also
▪Date
|