MicroStrategy ONE

ToDateTime (Convert String or Number to a Date or Timestamp)

The ToDateTime function converts a string of characters or a number into a date or timestamp.

Syntax

ToDateTime<Pattern=null>(Argument)

Where:

  • Argument is a fact, metric, column, or constant value that provides the strings that are converted to numeric values.
  • Pattern is a parameter that determines the date or timestamp format used for the resulting date or timestamp. By default, dates are expected to be of the format MM/dd/yyyy. When providing a pattern, enclose the pattern in double quotes (""). For example:

    ToDateTime<pattern="MM/dd/yyyy">(Day@ID)

    To specify a pattern, you can use custom formatting symbols that conform to the standards of the International Components for Unicode. For information about the custom formatting standards and syntax, see Formatting Dates and Times in the ICU Documentation.

Example

ToDateTime<pattern="MM/dd/yyyy">(Day@ID)

This example would return the data stored for the ID form of Day in a date format that includes month, day, and year information.