Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Returns an expression formatted as a date or time.

Syntax

FormatDateTime( Date [, NamedFormat ] )

The FormatDateTime function syntax has these arguments:

Argument

Description

Date

Required. Date expression to be formatted.

NamedFormat

Optional. Numeric value that indicates the date/time format used. If omitted, vbGeneralDate is used.

Settings

The NamedFormat argument has the following settings:

Constant

Value

Description

vbGeneralDate

0

Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed.

vbLongDate

1

Display a date using the long date format specified in your computer's regional settings.

vbShortDate

2

Display a date using the short date format specified in your computer's regional settings.

vbLongTime

3

Display a time using the time format specified in your computer's regional settings.

vbShortTime

4

Display a time using the 24-hour format (hh:mm).

Examples

Expression

Results

SELECT FormatDateTime([DateTime],0) AS Expr1 FROM ProductSales;

Formats and displays the date values in "DateTime" field into Date and/or time.

SELECT FormatDateTime([DateTime],1) AS NewDate FROM ProductSales;

Formats and displays the date values in "DateTime" field as Long Date format. Formats and displays the date values in "DateTime" field as Short Date format.

SELECT FormatDateTime([DateTime],3) AS NewDate FROM ProductSales;

Formats and displays the date values in "DateTime" field as "Time" format (without the date).

SELECT FormatDateTime([DateTime],4) AS NewDate FROM ProductSales;

Formats and displays the date values in "DateTime" field as 24hour "Time" format (without the date).

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×