• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 511
  • Last Modified:

Calculating No of days passed from getdate()

Hi,

I am using MSSQL 2005

I want no of days passed from the given date for example

If getdate() = 6 Nov

and pastDate = '2008-10-03 00:00:00.000'

Then I want no of days passed in integer

I am writting below query which is giving me date. But I want integer value, which tell no of days passed

select getDate()- CONVERT(datetime, '2008-10-03 00:00:00.000')

Thanks in Advance
0
tia_kamakshi
Asked:
tia_kamakshi
2 Solutions
 
Chandan_GowdaCommented:
select datediff(dd,'2008-10-03',getdate())
0
 
BinuthCommented:
try this
declare @dt as datetime
set @dt = cast('2008-10-03 00:00:00.000' as datetime)
 
select ABS(datediff(day,@dt,getDate()))

Open in new window

0
 
tia_kamakshiAuthor Commented:
Many Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now