Date Patterns
In Panorama, dates are represented as a number which is the number of days since January 1, 4713 B.C. For example, the date August 7, 1991 corresponds to the number 2,448,476. Most people aren’t too interested in knowing that a certain day is 2 million plus days from some pre-historic date. Date patterns allow you to control how dates are formatted when they are converted to text.

## Common Date Patterns

Panorama date patterns supports a wide variety of date formats. The table below lists several common date patterns. Date patterns must be surrounded by quotes.

`Date` | `Pattern` | `Display`
--- | --- | ---
`3/9/2002` | `mm/dd/yy` | `3/9/02`
`3/9/2002` | `MM/DD/YY` | `03/09/02`
`3/9/2002` | `mm-dd-yyyy` | `3-9-2002`
`3/9/2002` | `dd-MON-yy` | `9-MAR-02`
`3/9/2002` | `dd-Month-yy` | `9-March-02`
`3/9/2002` | `Month dd, yyyy` | `March 9, 2002`
`3/9/2002` | `Month ddnth, yyyy` | `March 9th, 2002`
`3/9/2002` | `DayOfWeek, Month ddnth, yyyy` | `Saturday, March 9th, 2002`
`3/9/2002` | `qq"q"yy` | `1q02`
`3/9/2002` | `"Week" ww "of" yyyy` | `Week 11 of 2002`
`3/9/2002` | `YYYYMMDD` | `20020309`
`5/23/2002` | `Quarter "Quarter" yyyy` | `Second Quarter 2002`
`7/11/2004` | `Qtr "Qtr" yyyy` | `3rd Qtr 2004`
`3/9/2002` | `"Day" dd, "Month" mm` | `Day 9, Month 3`
`3/1/2002` | `ddnth "day of" Month, yyyy` | `1st day of March, 2002`
`3/2/2002` | `ddnth "day of" Month, yyyy` | `2nd day of March, 2002`
`3/9/2002` | `ddnth "day of" Month, yyyy` | `9th day of March, 2002`
`3/1/1867` | `mmnth "month of" yyyy` | `3rd month of 1867`

## Components

There are 21 different basic components that can be used as part of a date pattern. A date pattern is built up by combining these components together with punctuation to build a complete pattern. Unlike Panorama 6 and earlier versions, components must be separated by one or more characters. There are 6 components that combine month day and year into a single component.

`Component` | `Example` | `Description`
--- | --- | ---
`yy` | `02` | `Year (within century)`
`yyyy` | `2002` | `Year (including century)`
`qq` | `2` | `Quarter (numeric)`
`qtr` | `2nd` | `Quarter (abbreviated)`
`quarter` | `second` | `Quarter (spelled out)`
`mm` | `9` | `Month (numeric)`
`MM` | `09` | `Month (with leading zero)`
`mon` | `sep` | `Month (abbreviated)`
`month` | `september` | `Month (spelled out)`
`ww` | `46` | `Week (within year)`
`dd` | `5` | `Day (numeric)`
`DD` | `05` | `Day (with leading zero)`
`day` | `tue` | `Day Of Week (abbreviated)`
`dayofweek` | `tuesday` | `Day Of Week (spelled out)`
`DDMMYY` | `3` | `Day, Month, Year (with no separators)`
`MMDDYY` | `3` | `Month, Day, Year (with no separators)`
`YYMMDD` | `3` | `Year, Month, Day (with no separators)`
`DDMMYYYY` | `3` | `Day, Month, Century, Year (with no separators)`
`MMDDYYYY` | `3` | `Month, Day, Century, Year (with no separators)`
`YYYYMMDD` | `3` | `Century, Year, Month, Day (with no separators)`

## Upper/Lower Case

Some of these components (qtr, quarter, mon, month, day, and dayofweek) can be either upper or lower case. The table below shows how a component can be displayed in all lower case, initial caps, or all upper case.

`Pattern` | `Display`
--- | ---
`month` | `september`
`Month` | `September`
`MONTH` | `SEPTEMBER`
`dayofweek` | `friday`
`DayOfWeek` | `Friday`
`DAYOFWEEK` | `FRIDAY`

## Quoted Literals

If you need to include the words qtr, quarter, mon, month, or day in your date, you must quote them so that they are not treated as components. Be sure to use regular straight quotes, not smart (curly) quotes. Since the text itself contains quotes, you will need to surround the pattern with a different quote character. In the following examples we have used {} as the quote characters surrounding each pattern.

`Pattern` | `Converted Text`
--- | ---
`{Quarter "Quarter" YYYY}` | `First Quarter 1992`
`{"Day" dd, "Month" mm}` | `Day 9, Month 3`

You can add the suffix nth to the mm, ww, or dd components, as shown below.

`Date` | `Pattern` | `Converted Text`
--- | --- | ---
`3/1/89` | `{ddnth "day of" Month}` | `1st day of March`
`3/2/89` | `{ddnth "day of" Month}` | `2nd day of March`
`3/9/89` | `{ddnth "day of" Month}` | `9th day of March`
`3/9/89` | `{Month ddnth, yyyy}` | `March 9th, 1989`
`3/9/89` | `{mmnth "month of" yyyy}` | `3rd month of 1989`

Panorama automatically adds the correct suffix.

See Also

- datepattern( -- converts a number representing a date into text. The function uses a pattern to control how the date is formatted (see Date Patterns).
- Field Properties -- available field attributes.