Skip to main content

DATESTR

Returns the date value of a DateTime as a string representation in either a standard or defined format.

For the syntax without the formatting being specified the default format used is determined by your local settings.

Syntax

string DATESTR(DateTime? value)

or

string DATESTR(DateTime? value, string format)

Example

For further explanation into the format of DateTime please follow the link to the Microsoft page on Custom Date and Time Format Strings

note

In the below example the local settings are UK standard so the format is day/month/year.

DATESTR(DATEVALUE("2017-10-09"))

Will return '09/10/2017'.


Alternatively you can specify the format to output as for example month.day.year hour:minute

DATESTR(DATEVALUE("2017-10-09 02:22"), "MM.dd.yyyy HH:mm")

Will return '10.09.2017 02:22'.

You can use a DateTime column from your datasets rather than using a fixed date value. For example if we used a created date column the expression used would be:

DATESTR(CreatedDate, "MM.dd.yyyy HH:mm")

You can modify the format as needed, for example if you wanted to return the month as a three character string representation (e.g. MAR) you can do so like this:

DATESTR(HireDate, "dd-MMM-yyyy")

This would return a value such as 15-Nov-1994.