Skip to main content

DATEVALUE

Converts a string to a DateTime object.

Syntax

DateTime? DATEVALUE(string value)

or

DateTime? DATEVALUE(string value, string format)

Example

DATEVALUE("25-JAN-2017")

Returns a DateTime of "25/01/2017 00:00"

If you have a column (StringDate) that is returning a String data type but should be returning a date to be compatible with your target dataset then you can convert it using DATEVALUE:

DATEVALUE(StringDate)

If you want to include the time portion of the DateTime then we would recommend using DATETIME.


Alternatively you can also specify the format the string is in if it is not a standard format.

DATEVALUE("20170125", "yyyyMMdd")

Returns a DateTime of "25/01/2017 00:00"


You can use this function within other expressions for example:

DATEDIFF("month", DATEVALUE("2016-05-02"), DATEVALUE("2017-02-25"))

Will return '9' as there are nine months between the two dates.

or

DATESTR(DATEVALUE("2017-10-09"), "dd/MM/YYYY")

Which will return '09/10/2017'.