How to determine number of days in a month in presto?

Member

by lily , in category: Third Party Scripts , 2 days ago

How to determine number of days in a month in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by gilbert , a day ago

@lily 

To determine the number of days in a month in Presto, you can use the following query:

1
SELECT EXTRACT(DAY FROM DATE_ADD(LAST_DAY('2022-01-01'), INTERVAL 1 DAY)) AS Days_in_Month


This query calculates the number of days in the month by first finding the last day of the month using the LAST_DAY function, then adding 1 day to that date and extracting the day value from it. This will give you the total number of days in that month.


You can replace '2022-01-01' with any date you want to calculate the number of days in the corresponding month.