Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

VBScript FormatDateTime Function

VBScript FormatDateTime Function


VBScript reference manual Complete VBScript Reference Manual


The FormatDateTime function formats and returns a valid date or time expression.

Syntax

FormatDateTime(date,format)

Parameters Description
date Required. Any valid date expression (such as Date() or Now()).
format Optional. A format value specifying the date/time format to use.

The following values can be used:

  • 0 = vbGeneralDate - Default. Returns a date: mm/dd/yy and, if a time is specified: hh:mm:ss PM/AM.
  • 1 = vbLongDate - Returns a date: weekday, monthname, year
  • 2 = vbShortDate - Returns a date: mm/dd/yy
  • 3 = vbLongTime - Returns a time: hh:mm:ss PM/AM
  • 4 = vbShortTime - Returns a time: hh:mm
  • |

    Example

    Example

    Display a date in different formats:

    The example above produces the following output:

    2/16/2010 1:45:00 PM

    Tuesday, February 16, 2010

    2/16/2010

    1:45:00 PM

    13:45

    Try it »


    VBScript reference manual Complete VBScript Reference Manual