Get day count for particular month using MS Sql


Hello,

By using below code you can find the day count-number of days in particular month

So here it is,

DECLARE @dtDate DATETIME
SET @dtDate = ‘8/18/2007’

select datediff(day, dateadd(day, 1-day(@dtDate), @dtDate),
dateadd(month, 1, dateadd(day, 1-day(@dtDate), @dtDate)))  as dayCount

you will get output like,

Capture

Here august month passed in dtDate parameter of sql so will have an output 31 day count.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: