Date returns a Variant of subtype Date; Date$ returns a String data type. Description
Returns the current system date. Rules at a Glance They don't come any easier than this! Programming Tips & Gotchas
• Although Date returns a Variant, you can assign the return value of Date to a variable declared as a Date data type.
194 Chapter 7- The Language Reference
• To return both the current date and time in one variable, use the Now function.
• You can set the system date by using the Date statement. See Also
Date Statement, IsDate Function, Now Function
Date Statement Named Arguments
Date = newdate newdate
Date Type: String, Date, or Date Variant Any valid date value.
• If you are setting the system date with numbers, as opposed to spelling the month, the sequence of Day, Month, and Year must be in the same sequence as the computer's regional settings.
• If you are running under Microsoft Windows, the earliest system date you can set is January 1, 1980; the latest system date you can set is December 31, 2099.
• For Microsoft Windows NT, the earliest and latest system dates are January 1, 1980 and December 31, 2079, respectively.
Date = "31 January 1998"
Programming Tips & Gotchas
• It's good programming practice to synchronize the dates across the machines in a multiuser environment, most commonly from the date on a server. This can be done at the operating-system level within the logon script or at application level using the Date and Time statements.
• To bulletproof your application from curious users who want to see what happens if they change the regional settings to Danish, your application from being installed on a new system on which the system administrator forgets to change the regional settings to your locale, and a host of other ways in which the computer your application is running on has regional settings different from those you expect, you should never take a date for granted. Wherever
Date Statement 195
possible, use the Format function to explicitly set the date format you require prior to using a date value.
• Modern windows systems are more reliant on the system date than ever before. A single machine can have literally hundreds of different applications installed, many of which will use dates in one way or another. You should respect the machine on which your application is running and only in very exceptional circumstances should you change the system date programmati-cally.
Date Function, IsDate Function
Was this article helpful?