I have the following date 2022-08-21
in the DateCol of a table and I would like to format this as August 2022
. I tried the following format_datetime(DateCol, 'MMMM yyyy')
but that return 0808 2022
.
The format specifiers in the question are working as expected:
MM formats the month, from 01 through 12. You have MMMM so two times MM thats why 0808.
yyyy formats the year as a four-digit number. Thats why 2022.
Month is only supported as a numeric value so you can use something like:
let months = dynamic({"1":"January", "2":"February", "3":"March","4":"April","5":"May","6":"June","7":"July","8":"August","9":"September","10":"October","11":"November","12":"December"});
let fullDate = datetime(2022-08-21);
print strcat(months[tostring(getmonth(fullDate))], " ", getyear(fullDate))
Check usage of datetime_part(), monthofyear(),getyear() for further information