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

Member

by lily , in category: Third Party Scripts , 5 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by gilbert , 5 months 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.

Related Threads:

How to get date string from day number and month number using moment.js?
How to get month name from date in presto?
How to parse month-year string using presto?
How to get year and month into number oracle?
How to convert time interval in oracle to number of days in oracle?
How to declare month to be within current_month only in presto?