Forum Discussion
Anonymous
5 years agoNot applicable
Dynamic Date Field
I have a coworker that created a date field in a dashboard (see below). Based on today's date the field would read 2021-6. My concern is how will this field appear once we reach January 2022. How ...
- 5 years ago
Hello Anonymous,
You're right, the code for your month Display wouldn't return the correct result for January 2022.
You can create a measure with this code :VAR _LastMonth = EOMONTH( TODAY(), -1) VAR _Formatted = FORMAT( _LastMonth, "YYYY-MM") RETURN _Formatted
Example :
If today's date is 2022-01-06,
The first variable will return 2021-12-31
The second variable will format the result to show 2021-12
You can also change the format to "MMM YYYY" if you want.
m3tr01d
5 years agoContinued Contributor
Hello Anonymous,
You're right, the code for your month Display wouldn't return the correct result for January 2022.
You can create a measure with this code :
VAR _LastMonth = EOMONTH( TODAY(), -1)
VAR _Formatted = FORMAT( _LastMonth, "YYYY-MM")
RETURN _Formatted
Example :
If today's date is 2022-01-06,
The first variable will return 2021-12-31
The second variable will format the result to show 2021-12
You can also change the format to "MMM YYYY" if you want.