You are here: Reference > Date Time Functions

Date/Time Functions

You can use the following functions in the expression editor to create, manipulate, and format date and time strings. The functions take dates or strings as input, and then return strings as output. The native format of the functions is:

yyyy-mm-dd HH:MM:SS

For example: 2016-02-10 14:55:00

If a date/time string is in this format, Alteryx can use it directly without parsing – you can use the Select tool to change to an appropriate data type. If a date/time string is not in this format, use the Date/Time tool or DateTimeParse function to convert the string to a format Alteryx can use.

The functions will report field conversion errors if they are given bad input, or if a parsed date does not match the expected format. Strings that use the correct syntax but denote invalid dates (for example, 2015-02-29 – a nonexistent date) will also produce field conversion errors.

Format Specifiers, Separators, and Examples

Date/Time specifiers are used by the DateTimeParse and DateTimeFormat functions. Alteryx defines the parts of a date/time with these specifiers, which are gathered together into a format string.  This string is then passed to Alteryx to tell it how to handle the dates in a particular part of the program. Format specifiers are used in both reading and writing dates and always begin with a percent sign (%), followed by a case-sensitive letter.  

For example, the common (US) format of 03/13/2006 is specified with the string %m/%d/%Y

The format string used for reading a date should match the data as closely as possible. Alteryx will accept either '/' (forward slash) or '-' (hyphen) separators when reading a date. However, ',' (comma), ':' (colon), and all other separators must match exactly or the input data will be reported as an error.

For example: you can parse the date 03/20/04 with the format string %d/%m/%y, while the date 07-04-2006 needs %d-%m-%Y.

Related Topics Link IconRelated Topics