DateFormat

Formats date-time values into strings using the chosen format or 'mask'.

  • Returned Output: Date-Time
  • Library: PQL \ Common \ Date-Time
  • Version: 2018.00.000
  • Compatibility:
    • Can be combined with and other PQL function throughout the application.
    • It CANNOT be used with MDX or VBA functions. But it can be used on MDX-based content in other parts of the application.

Syntax

DateFormat( <Date-Time> , <Mask> )

* Click on the function's arguments above for more details on the input values.

Comments
  • The date time value can be any element that resolves to a date-time value.
  • The text mask is a prescribed input that instructs the engine on how to format the date or time.
  • Format produces a text string. It cannot be used for subsequent date time operations.
Different Function types
  • This function is like the Excel Format function.
  • Use the Format function to format numbers.

Masks

The syntax for describing a date-time format mask is based on Java specifications. Details on the specification can be found here.

Examples

This produces "2019-Apr-08 14:35:00.2". The date-time value is generated from the "dateTime" function, which gets the current date-time of the system.

DateFormat(dateTime(), "yyyy-MMM-dd HH:mm:ss.S")

This produces 06-18. The date-time value is generated from a another string using the "StringToDateTime" function.

DateFormat(StringToDateTime("2018-01-05")), "MM-yy")

This produces 2018-1 for the first week in 2018.

DateFormat(StringToDateTime("2018-01-05")), "yyyy-w")