C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...









Find Difference Between Two Dates using MS SQL


Posted Date: 16 Jul 2008    Resource Type: Code Snippets    Category: SQL

Posted By: Dilip Kumbhar       Member Level: Gold
Rating:     Points: 7



The following code sample helps to find the difference between two dates.

First, we provide the syntax to perform such an operation

DATEDIFF ( datepart , startdate , enddate )


Here are few examples on how ti use the function


SELECT DATEDIFF(day, '1/1/2008' ,getdate()) AS no_of_days

Returns the difference in days from 1st Jan 2008.


SELECT DATEDIFF(month, '1/1/2008' ,getdate()) AS no_of_days

Returns the difference in months from 1st Jan 2008.


SELECT DATEDIFF(year, '1/1/2008' ,getdate()) AS no_of_days

Returns the difference in years from 1st Jan 2008.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Using DATEDIFF:DATEDIFF examples  .  Use MS SQL to find Difference between two dates  .  Microsoft MS Sql  .  Find Difference Between Two Dates using MS SQL  .  Find Difference Between Two Dates  .  Difference Between Two Dates using MS SQL  .  Difference Between Two Dates  .  DATEDIFF function  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: CASE Statements in SQL Server
Previous Resource: Rounding numbers in MS SQL
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

internet fax

Contact Us    Privacy Policy    Terms Of Use