.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

How to count number of Days present?

Posted By: Syed Shakeer Hussain     Posted Date: August 22, 2009    Points:2   Category :Sql Server
How to count number of Days present FromDate to TODate using Sql
eg:12-08-1985 to 12-09-2009(dont count days with year.i want only days in between the moth 08 and 09)

Responses
Author: Amit Mehra             
Posted Date: August 22, 2009     Points: 5   

Hi Syed,

You can use datediff() sql server function to get the difference in terms of number of days

for eg

select datediff(day,'5/25/1985','4/24/2009')


the above sql satement will you the number of days 8735

Hope i understood your question correct.

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Syed Shakeer Hussain             
Posted Date: August 22, 2009     Points: 5   

Hi Amit,

That is not a answer.

suppose i have two dates ''23-08-2009'' and 05-09-2009.I want how many days in between these two dates.(only take in between month)
answer will be:
13 days


Author: Amit Mehra             
Posted Date: August 22, 2009     Points: 5   

Hi Syed,

I have tested the above code with your given date as in input and it will return 13 days as answer

select datediff(day,'8/23/2009','9/5/2009')

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Syed Shakeer Hussain             
Posted Date: August 22, 2009     Points: 5   

Nice query Amith.
Thank you

Author: Amit Mehra             
Posted Date: August 23, 2009     Points: 5   

My Pleasure Syed...

Thanks,
Amit
Please "Mark As Answer " if this post help you.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend