O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Month Function

Syntax

Month(date)
date

Use: Required

Data Type: Date

Any valid date expression.

Return Value

An Integer between 1 and 12.

Description

Returns a variant representing the month of the year of a given date expression.

Rules at a Glance

If date contains Null, Month returns Null.

Programming Tips and Gotchas

  • The validity of the date expression and the position of the month element within the date expression are initially determined by the locale settings of the current Windows system. However, some intelligence has been built into the Month function that surpasses the usual comparison of a date expression to the current locale settings. For example, on a Windows machine set to U.S. date format (mm/dd/yyyy), the date “13/12/2000” is technically illegal. However, the Month function returns 12 when passed this date. The basic rule for the Month function is that if the system-defined month element is outside legal bounds (i.e., greater than 12), the system-defined day element is assumed to be the month and is returned by the function.

  • Since the IsDate function adheres to the same rules and assumptions as Month, it determines whether a date is valid before passing it to the Month function.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required