© J R Stockton, ≥ 2012-11-18

VBScript Date and Time Index.

Links within this site :-

There page is a snapshot, taken on or after 2013-01-19.


! ! This page expects VBScript ! !

It seems unlikely that code on this page will work in many browsers other than Microsoft Internet Explorer.

Its methods can be used in Windows Script Host and in other Microsoft applications, such as Excel.

Analogous code, and more, can be found via JavaScript Date and Time.

VBScript is invoked (with Option Explicit) as the first scripting on this page → ←.

Introduction

VBScript Date and Time are Gregorian and Local; Summer Time is disregarded. The date range is a daycount from 0100-01-01 to 9999-12-31 inclusive (-657434 to 2958465 days from CDate(0) = Saturday 1899-12-30 00:00 = CMJD 15018.0); WeekDay default is Sun=1 to Sat=7 (an optional second parameter controls week start). The CDate of a day is 5 decimal digits from 1927-05-18 to 2173-10-13.

Your system is set to display a VBScript CDate as

That should be remembered when reading on; the format is I believe set by Windows Control Panel, Regional Settings. Here, some computed dates are presented thus, while others are coded explicitly in ISO 8601 form, as 1616-04-23 18:30:00.

Anything involving VBScript built-in conversions between String and CDate may be affected by OS localisation.

Interpretation of the fractional part of a negative CDate is quaint on my system; it may depend on version :-

document.write CDate(+1.1), " ; ", CDate(-1.1)
gave me, in IE4, "1899-12-31 02:24:00 ; 1899-12-29 02:24:00"

Delphi behaves similarly.

Miscellaneous

For discussion of the ill-determined question of expressing a difference in dates in terms of years, months, and days, see in JavaScript Date and Time 1 : Date Arithmetic, and links.

VBScript Date and Time 1, VBScript Date and Time 2,
VBScript General and Maths, with VBS Pages Introduction
JavaScript Date and Time
Home Page
Mail: no HTML
© Dr J R Stockton, near London, UK.
All Rights Reserved.
These pages are tested mainly with MS IE 8 and Firefox 3.0 and W3's Tidy.
This site, , is maintained by me.
Head.