Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateAdd Function

Status
Not open for further replies.
Joined
Mar 20, 2009
Messages
102
Location
US
I have the below formula:

SELECT DATEADD(year, -1, getdate()) - which returns:
2008-07-21 12:03:32.733
--I need it to return the time as 00:00:00.00

Also in my report what I need to accomplish is a date range:

checkdate between DATEADD(year, -1, getdate()) and 30 days(the previou 30 days). In other words:

checkdate between '6-21-2008' and '7-21-2008'

Any help on this would be greatly appreciated!!

Thanks a million.....
 
Code:
declare @d datetime
set @d = DATEADD(year, -1, getdate())
SELECT @d, cast(CONVERT(varchar(30),@d,112) as datetime)
 
Code:
SELECT DATEADD(yy,-1,DATEADD(dd,0,DATEDIFF(dd,0,GETDATE())))

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
markros,
PLEASE do not call me Borislav.
That way all call me when I do something wrong :-)
Boris is enough :-)

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Boris,

I also introduced a typo in your full name - sorry.

May I call you Bor for short? :) Just kidding.
 
You can call me whatever you like :-))))
Just not Borislav :-)

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top