Microsoft KB Archive/252734

From BetaArchive Wiki
Knowledge Base

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

Article ID: 252734

Article Last Modified on 11/17/2003


  • 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


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.


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.


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

Keywords: kbbug kbpending KB252734