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

Day Function

Syntax

Day(dateexpression)
dateexpression

Use: Required

Data Type: Any valid date expression

Any expression capable of conversion to a Date.

Return Value

Variant of type Integer.

Description

Returns a variant integer data type that can take on a value ranging from 1 to 31, representing the day of the month of dateexpression. dateexpression, the argument passed to the Day function, must be a valid date/time or time value.

Rules at a Glance

  • dateexpression can be any variant, numeric expression, or string expression that represents a valid date.

  • The range of dateexpression is 1/1/100 to 12/31/9999.

  • If dateexpression is Null, Null is returned.

Programming Tips and Gotchas

  • When working with dates, always check that a date is valid using the IsDate function prior to passing it as a function parameter.

  • If dateexpression omits the year, Day still returns a valid day.

  • If the day portion of dateexpression is outside its valid range, the function generates runtime error 13, “Type mismatch.” This is also true if the day and month portion of dateexpression is 2/29 for a nonleap year.

  • To return the day of the week, use the WeekDay 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