Format

For dates and times only. Defines a format for the expression's return values.

Syntax

Format(Expression, [Format], [First_Day_Of_Week], [First_Week_Of_Year])

Parameters

Expression
The MDX expression to format.
Format
The format to apply to the expression's return values. This parameter supports the following values:
  • dd: The day of the month, with a leading zero: 01-31.
  • d: The day of the month, with no leading zero: 1-31.
  • mmmm: The full month name.
  • mmm: The abbreviated month name.
  • mm: The month of the year, with a leading zero: 01-12. Begins with January (01).
  • m: The month of the year, with no leading zero: 1-12. Begins with January (1).
  • yyyy: The full three- or four-digit year: 100-9999.
  • yy: The last two digits of the year: 00-99.
  • y: The day of the year: 1-366.
  • ww: The week of the year, with no leading zero: 1-53. Week 1 begins on January 1.
  • WW: The week of the year, with a leading 0: 01-53. Week 1 begins on January 1.
  • w: The day of the week, with no leading zero: 1-7.
First_Day_Of_Week

The day to use as the first day of the week. This parameter supports the following values:

  • vbUseSystem
  • vbSunday
  • vbMonday
  • vbTuesday
  • vbWednesday
  • vbThursday
  • vbFriday
  • vbSaturday

The default value is controlled by the query.language.mdx.vba.format.firstdayofweek engine setting. The default value of this setting is vbSunday. For more information, see Query Settings.

First_Week_Of_Year

The week to use as the first week of the year. This parameter supports the following values:

  • vbUseSystem
  • vbFirstJan1: The week of January 1.
  • vbFirstFourDays: The first week with four days that fall in the year.
  • vbFirstFullWeek: The first full week of the year.

The default value is controlled by the query.language.mdx.vba.format.firstweekofyear engine setting. The default value of this setting is vbFirstJan1. For more information, see Query Settings.

Example

The following example returns the current date in yyyymmdd format:

[Order Date Dimension].[Order Date Month Hierarchy].[Day].&[`CInt(Format(Now(), "yyyymmdd"))`]