Forum Discussion
mtrevisiol
4 years agoHelper V
Calendar with IF statement
Hi everyone. I would like to create a Calendar table that contains all the dates of the previous 12 months + dates until today. For example, if today is 3rd December 2021, the table would contain d...
- 4 years ago
Hi mtrevisiol ,
Your question is not much clear to me but the code which you are trying needs to be written as mentioned below:
MyCalendar = VAR decreased_month = MONTH ( TODAY () ) - 1 VAR start_date = IF ( decreased_month > 0, DATE ( YEAR ( TODAY () ) - 1, decreased_month, 1 ), DATE ( YEAR ( TODAY () ) - 2, decreased_month + 12, 1 ) ) RETURN CALENDAR ( start_date, TODAY () )Thanks,
Samarth
Samarth_18
4 years agoCommunity Champion
Hi mtrevisiol ,
Your question is not much clear to me but the code which you are trying needs to be written as mentioned below:
MyCalendar =
VAR decreased_month =
MONTH ( TODAY () ) - 1
VAR start_date =
IF (
decreased_month > 0,
DATE ( YEAR ( TODAY () ) - 1, decreased_month, 1 ),
DATE ( YEAR ( TODAY () ) - 2, decreased_month + 12, 1 )
)
RETURN
CALENDAR ( start_date, TODAY () )Thanks,
Samarth