Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Compare a date variable with today's date
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cullyK
Starting Member

5 Posts

Posted - 02/06/2007 :  12:40:06  Show Profile  Reply with Quote
ok so I am guessing you use the datediff function but not sure how to get the output i actually want.

I have a variable @mydate I want to see if it is before or on todays date.

Is it something like
if not DATEDIFF(day,getDate(),@mydate) > 1
begin
--then @mydate is a date before today
End

having a hard time testing this, thanks

SwePeso
Patron Saint of Lost Yaks

Sweden
30421 Posts

Posted - 02/06/2007 :  13:12:29  Show Profile  Visit SwePeso's Homepage  Reply with Quote
if @mydate < getdate()
select 'yesterday or before'
else
select 'the future!'

if datediff(day, @mydate, getdate())) > 0
select 'yesterday or before'
else
select 'the future!'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

cullyK
Starting Member

5 Posts

Posted - 02/07/2007 :  04:05:20  Show Profile  Reply with Quote
thank you sir
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000