Working With Dates and Times in VBScript
(Page 1 of 6 )
VBScript provides a wide variety of support for working with dates and times. It offers a number of different functions geared toward retrieving the current date and time, calculating past and future dates and times, and comparing dates and times.
Since there are so many functions available, the key to learning and use them all is to break them down into groups based on what they do. This simplified approach will help you to remember them more easily.
It’s important to understand that VBScript treats dates and times as a numeric sub-type and provides an actual data type for them. This allows VBScript to perform date and time calculations more easily.
Dates and times in VBScript are handled according to the VT_Date specification. Among other things, this determines the range of dates that VBScript will accept, the precision of those dates and times, and the manner in which they are handled internally. This also means that dates and times are based upon the system clock as well as the current system’s regional date and time settings. Scripters should be aware that this creates inherent flaws when working with dates and times from remote systems and when performing calculations on dates and times that span multiple time zones.
Finally, scripters should also be aware that VBScript will support nearly every acceptable date and time format. This means that scripts written in different areas of the world may look very different. You should know your intended audience very well when implementing dates and times in your scripts. For instance, does your target audience use a 12 or 24-hour clock? Do they list dates with the month or day first? What language are weekday and month names in? Is Sunday the first day of the week or do they use a completely different calendar altogether?
Next: Retrieving the date and time >>
More Windows Scripting Articles
More By Nilpo