VBScript Tutorials - Herong's Tutorial Examples - Version 5.20, by Dr. Herong Yang

Built-in Date and Time Functions

This section provides a list of commonly used built-in date and time functions.

VBScript supports the following commonly used date and time functions:

  • CDate(vVariant) - Converts a valid date and time expression to the variant of subtype Date
  • Date() - Returns the current system date
  • DateAdd(sType, iInterval, tDate) - Returns a date to which a specified time interval has been added
  • DateDiff(tDate1, tDate2) - Returns the number of intervals between two dates
  • DatePart(sType, tDate) - Returns the specified part of a given date
  • DateSerial(iYear, iMonth, iDate) - Returns the date for a specified year, month, and day
  • DateValue(vVariant) - Returns a date
  • Day(tDate) - Returns a number that represents the day of the month (between 1 and 31, inclusive)
  • FormatDateTime(tDate, iType) - Returns an expression formatted as a date or time
  • Hour(tDate) - Returns a number that represents the hour of the day (between 0 and 23, inclusive)
  • IsDate(vVariant) - Returns a Boolean value that indicates if the evaluated expression can be converted to a date
  • Minute(tDate) - Returns a number that represents the minute of the hour (between 0 and 59, inclusive)
  • Month(tDate) - Returns a number that represents the month of the year (between 1 and 12, inclusive)
  • MonthName(iMonth) - Returns the name of a specified month
  • Now() - Returns the current system date and time
  • Second(tDate0 - Returns a number that represents the second of the minute (between 0 and 59, inclusive)
  • Time() - Returns the current system time
  • Timer() - Returns the number of seconds since 12:00 AM
  • TimeSerial(iHour, iMinute, iSecond) - Returns the time for a specific hour, minute, and second
  • TimeValue(tDate) Returns a time
  • Weekday(tDate) - Returns a number that represents the day of the week (between 1 and 7, inclusive)
  • WeekdayName(iWeekDay) - Returns the weekday name of a specified day of the week
  • Year(tDate) - Returns a number that represents the year

Table of Contents

 About This Book

 Introduction of VBScript - Visual Basic Scripting Edition

 Variant Data Type, Subtypes, and Literals

 Arithmetic Operations

 Numeric Comparison Operations and Logical Operations

 String Operations - Concatenation and Comparison

 Variable Declaration and Assignment Statement

 Expression and Order of Operation Precedence

 Statement Syntax and Statement Types

 Array Data Type and Related Statements

 Array References and Array Assignment Statements

 Conditional Statements - "If ... Then" and "Select Case"

 Loop Statements - "For", "While", and "Do"

 "Function" and "Sub" Procedures

Built-in Functions

 Built-in Math Functions

 Built-in Conversion Functions

 Built-in String Functions

Built-in Date and Time Functions

 Built-in Array Functions

 Built-in Misc. Functions

 Inspecting Variables Received in Procedures

 Error Handling Flag and the "Err" Object

 Regular Expression Pattern Match and Replacement

 scrrun.dll - Scripting Runtime DLL Library

 Creating Your Own Classes

 IE Web Browser Supporting VBScript

 IIS ASP Server Supporting VBScript

 WSH (Windows Script Host)

 References

 Printable Copy - PDF Version

Built-in Date and Time Functions - Updated in 2015, by Dr. Herong Yang