Export (0) Print
Expand All
Expand Minimize

DATETIME Function

Last modified: June 17, 2011

Applies to: Office 2013 | Visio 2013

In this article
Syntax
Remarks
Example 1
Example 2
Example 3
Example 4

Returns the date and time value represented by datetime or expression.

DATETIME("datetime"|expression[,lcid])

Parameters

Name

Required/Optional

Data Type

Description

datetime

Required

String

Any string commonly recognized as a date and time or a reference to a cell containing a date and time.

expression

Required

String

Any expression that yields a date and time.

lcid

Optional

Number

Specifies the locale identifier to be used in evaluating a non-local datetime. The locale identifier is a number described in the system header files.

Return Value

Datetime

If datetime is missing or cannot be interpreted as a valid date or time, DATETIME returns a #VALUE! error.

The returned value is formatted according to the short date style and time style in the system's current Regional Settings.

The DATETIME function also accepts a single number value for expression where the integer portion of the result represents the number of days since December 30, 1899, and the decimal portion represents the fraction of a day since midnight.

DATETIME("May 30, 1997")+5 ed.

Returns the value representing 6/4/1997.

FORMAT(DATETIME("5/20/1997 14:30:45"),"C")

Returns the string "Tuesday, May 20, 1997 2:30:45 PM."

DATETIME("1:30 PM July 19")

Returns the value representing 7/19/2001 1:30:00 PM (assuming the current year is 2001).

DATETIME(35580.6337)

Returns the value representing 5/30/1997 3:12:32 PM.

Show:
© 2014 Microsoft