FormatDate

Returns a formatted date-string.

Syntax

FormatDate ( date, internal-date-format )
ParameterDescription

date

A number representing the input date between January 1, 1970 and Dec 31, 2037. The number is the number of seconds elapsed since midnight, January 1, 1970. To retrieve this number, use any of the following functions: Today(), TodateEx(), GetFirstDate(), GetLastDate(), DateRoll().

Date-time attribute properties of a member can also be used to retrieve this number. For example,

  • Product.currentmember.[Intro Date] returns the product introduction date for the current product in context.

  • [Cola].[Intro Date] returns the product introduction date for Cola.

internal-date-format

One of the following literal strings (excluding ordered-list numbers and parenthetical examples) indicating a supported date format.

  1. "mon dd yyyy" (Example: mon = Aug)

  2. "Month dd yyyy" (Example: Month = August)

  3. "mm/dd/yy"

  4. "mm/dd/yyyy"

  5. "yy.mm.dd"

  6. "dd/mm/yy"

  7. "dd.mm.yy"

  8. "dd-mm-yy"

  9. "dd Month yy"

  10. "dd mon yy"

  11. "Month dd, yy"

  12. "mon dd, yy"

  13. "mm-dd-yy"

  14. "yy/mm/dd"

  15. "yymmdd"

  16. "dd Month yyyy"

  17. "dd mon yyyy"

  18. "yyyy-mm-dd"

  19. "yyyy/mm/dd"

  20. "Long format" (Example: "WeekDay, Mon dd, yyyy")

  21. "Short format" (Example: "m/d/yy")

Notes

Example

The following query returns the first 10 day sales for all Colas products since their release date in the market California.

WITH MEMBER 
 Measures.[first 10 days sales] AS 
  'SUM(
     LastPeriods(-10, 
      StrToMbr(
       FormatDate("Mon dd yyyy", Product.CurrentMember.[Intro Date]) 
          )
         )
  , Sales)'
SELECT
 {[first 10 days sales]} 
ON COLUMNS,
 {Colas.Children}
ON ROWS
FROM MySamp.basic
WHERE (California, Actual);