BUG: Date() and Now() Return Wrong Year in 16-Bit VBScript (252734)



The information in this article applies to:

  • Microsoft Visual Basic, Scripting Edition 3.0
  • Microsoft Visual Basic, Scripting Edition 4.0
  • Microsoft Visual Basic, Scripting Edition 5.0

This article was previously published under Q252734

SYMPTOMS

Visual Basic Script (VBScript) functions that calculate the current date might incorrectly calculate the year. For example, for January 24, 2000, the Date function returns 1/24/100 rather than 1/24/2000. The following functions are affected:
  • Date
  • Now
The bug does not affect the Time function because the date portion is masked off.

CAUSE

The 16-bit version of VBScript uses a call to localtime() to get the current time. This call returns a struct tm, the tm_year member of which contains the current year minus 1900.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

Modification Type:MajorLast Reviewed:11/17/2003
Keywords:kbBug kbpending KB252734