RSS

SQL Server – How to Find Total Number of Days in a Month

12 Apr
To Find out Total Number Of day in any month in Sql Server we have to write these Query :
Select datediff(day, GetDate(), dateadd(month, 1, GetDate()))
By using above query we can get total number of days for particular month.
Advertisements
 
 

2 responses to “SQL Server – How to Find Total Number of Days in a Month

  1. Jonathan

    May 14, 2013 at 6:40 pm

    i will not work for every date
    try for 1/31/2013 or 3/31/2013 or 5/31/2013

    all these months are of 31 days but for above date result will be 28, 30 and 30

    For correct answer see

    http://advancesharp.com/blog/1070/how-to-get-number-of-days-in-a-month-in-sql-server

     
    • Anil Shah

      May 15, 2013 at 1:56 pm

      Thanks For Your Reply.
      I have Seen Your Solution. And I found This is right.
      I will Change my Code As Per Your Solution.

       

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: