sql server - How do I get the number of days in a month for the specific date in that row of data using SQL? -
for example, if have data set including 2 columns, 1 shows month number , other shows year (result of grouping data using group by), want add column called 'days in month' display number of days in respective month. there way can this? there function can add in select clause?
i want since there further calculations need number each row.
in sql server 2012+, can use:
select day(eomonth(datecol)) eomonth() gets last day of month. day() returns day of month -- number of days in month, in case.
Comments
Post a Comment