Get the number of days in a month

General
Enthusiast

Get the number of days in a month

Hi

Please assist I need to get the number of days in a month to do a calculation eg. 31, 28, 30 ect, in SQL i would do someting like this, but I'm stuck in Teradata.

select DAY(DATEADD(mm, DATEDIFF(mm, -1, GETDATE()), -1))

3 REPLIES
Enthusiast

Re: Get the number of days in a month

One Way:

sel month_of_year, max(day_of_month) from  sys_calendar.calendar where year_of_calendar = 2015 group by 1 order by 1;

Rglass

Enthusiast

Re: Get the number of days in a month

thanks Glass it worked perfectly !

Rgds

Jx

Junior Contributor

Re: Get the number of days in a month

TD14: 

SELECT  EXTRACT(DAY FROM LAST_DAY(CURRENT_DATE))