Description
The DateFormatGen Generator re-formats a date from referenced calendar Attribute. If the referenced Attribute does not return a date value, then the DateFormatGen Generator will output the referenced Attribute result as it is.
In This Article
- Generator Parameters
- selectedFormat Parameter
- Use Case 1 - Reference a Generated Date and Output the Day's Long Name
- Use Case 2 - Reference a Generated Date and Output the Week in the Year
- Use Case 3 - Manually Format Referenced Date as MM/dd in Output
Generator Parameters
The following parameters may be configured for the DateFormatGen Generator. Items with an asterisk* are required.
- referenceDate* - Defines the Attribute to reference. This Attribute must return a formatted date value. A constant value can also be entered for this parameter.
- referenceFormat* - Defines the date format of the Attribute being referenced. It must match the date format of what has been defined for the referenced Attribute, or the generated values will not be accurate.
- manualFormat - Defines a format that you, the user, may enter. This value will override a selected format.
- selectedFormat* - If a manualFormat is not defined, then the value of the selectedFormat will be used to format the referenced date.
- upperCase* - When true, the formatted date will be converted to all uppercase.
selectedFormat Parameter
These values are possible for this parameter:
Option | Description | Output Values | Example |
DAY_NAME_SHORT | Short name of the week based on the referenced date. | Mon, Tues, Wed, Thurs, Fri, Sat, Sun | Date = 01-01-2022 Output = Sat |
DAY_NAME_LONG | Long name of the week based on the referenced date. | Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday | Date = 01-01-2022 Output = Saturday |
DAY_IN_WEEK | Number value for the day of the week based on the referenced date. | 1, 2, 3, 4, 5, 6, 7 | Date = 01-01-2022 Output = 6 |
DAY_IN_MONTH | Number value of the day in the month based on referenced date. | 1 - 31 | Date = 05-26-2022 Output = 26 |
DAY_IN_YEAR | Number value of the day in a year based on the referenced date. | 1 - 365 | Date = 02-01-2022 Output = 32 |
WEEK_IN_MONTH | Number value for the week in that month based on the referenced date. | 1 - 5 | Date = 02-24-2022 Output = 4 |
WEEK_IN_YEAR | Number value for the week in the year based on the referenced date. | 1 - 56 | Date = 02-24-2022 Output = 9 |
MONTH_NAME_SHORT | Short name of the month in the referenced date. | Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec | Date = 06-09-2022 Output = Jun |
MONTH_NAME_LONG | Long name of the month in the referenced date. | January, February, March, April, May, June, July, August, September, October, November, and December | Date = 06-09-2022 Output = June |
MONTH_IN_YEAR | Number value for the month in the referenced date. | 01 - 12 | Date = 06-09-2022 Output = 06 |
YEAR_SHORT | The 2-digit number value of the year in the referenced date. | 70, 80, 90, 00, 10, 20, 25 | Date = 01-01-1970 Output = 70 |
YEAR_LONG | The 4-digit number value of the year in the referenced date. | 1970, 1980, 1990, 2000 | Date = 01-01-1970 Output = 1970 |
QUARTER | Number value for the quarter of the year the referenced date falls in. | 1 - 4 | Date = 07-01-2022 Output = 3 |
Use Case 1 - Reference a Generated Date and Output the Day's Long Name
For this example, an Attribute has been set up with two linked Generators. This makes it easy to show the original date and how it will be formatted.
gen1 (startDate) - The FlexibleDateJumpGen Generator generates a date formatted like this: MM-dd-yyyy.
gen 2 (formattedDate) - The DateFormatGen Generator format the generated date based on what has been selected within the Generator parameters.
- referenceDate - References gen1 (startDate) Generator
- referenceFormat - The format used by the gen1 (startDate) Generator
- selectedFormat = DAY_NAME_LONG
Use Case 2 - Reference a Generated Date and Output the Week in the Year
The setup is the same as in Use Case 1 above, except WEEK_IN_YEAR has been selected for the selectedFormat parameter.
Use Case 3 - Manually Format Referenced Date as MM/dd in Output
The manualFormat parameter can be used to override the format option that is selected within the selectedFormat parameter.
Here are three examples of what can be entered for the manualFormat parameter:
- MM/dd = Two-digit month and two-digit day (e.g., 01/05)
- MM-yyyy = Two-digit month and four-digit year (e.g., 01-1980)
- MM/yyyy = Two-digit month and four-digit year (e.g., 01/1970)
This example uses the same setup as Use Case 1 and Use Case 2, with the addition of the manualFormat parameter value.
Output