Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

VBScript FormatDateTime function


May 13, 2021 VBScript


Table of contents


VBScript FormatDateTime function

The VBScript FormatDateTime function returns an expression formatted as a date or time.


VBScript FormatDateTime function Complete VBScript reference manual

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

Grammar

FormatDateTime(date,format)

Parameters

parameter describe
date Required.Any valid date expression (such as Date () or now ()).
format Optional.Specifies the format value of the date / time format used.

The following value can be used:

  • 0 = VBGENERALDATE - the default.Return Date: MM / DD / YY and if specified time: hh: mm: SS PM / AM.
  • 1 = VBLONGDATE - Back Date: Weekday, Monthname, Year
  • 2 = VBSHORTDATE - Back Date: mm / dd / yy
  • 3 = vblongtime - Return Time: hh: mm: SS PM / AM
  • 4 = VBSHORTTIME - Return Time: hh: mm

Show dates in different formats:

<script type="text/vbscript">

d=CDate("2010-02-16 13:45")
document.write(FormatDateTime(d) & "<br />")
document.write(FormatDateTime(d,1) & "<br />")
document.write(FormatDateTime(d,2) & "<br />")
document.write(FormatDateTime(d,3) & "<br />")
document.write(FormatDateTime(d,4) & "<br />")

</script>

The above example output results:

2/16/2010 1:45:00 PM
Tuesday, February 16, 2010
2/16/2010
1:45:00 PM
13:45

Try it out . . .


VBScript FormatDateTime function Complete VBScript reference manual