How to get date difference beween two date in SQL

sam
sam
Member
378 Points
48 Posts

Hi,

I am working in SQL . I need age for the user till date. How to get date difference beween current date and date of birth in SQL?

Views: 8792
Total Answered: 1
Total Marked As Answer: 0
Posted On: 01-Dec-2015 06:16

Share:   fb twitter linkedin
Answers
Smith
Smith
None
2568 Points
74 Posts
         

Hi Sam,

You can use DateDiff method in SQL as

Syntax:

DATEDIFF(datepart,startdate,enddate)

Description:

datepart is one of the following

datepartAbbreviation
year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
weekday dw, w
hour hh
minute mi, n
second ss, s
millisecond ms
microsecond mcs
nanosecond ns

Example:

SELECT DATEDIFF(day,'2015-06-05','2015-08-05') AS DiffDate
Posted On: 01-Dec-2015 06:54
 Log In to Chat