find number of days in a month from ms sql server

1
30

to find no of days in a month in sql apply a simple logic

take difference in number of days to the next months date with day that of current date

for this use datediff and dateadd functions

syntax
datediff(d,getdate(),dateadd(m,1,getdate()))

here datediff is for difference and dateadd is for fetching next months date

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here