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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to identify age from date 2

Status
Not open for further replies.

jararaca

Programmer
Jun 1, 2005
159
0
0
US

Hi,

I have a table with a smalldatetime column. I need to identify all records in that table that have dates in that column that are six months old or older. Can someone please tell me how I might do this?

Thank you.
 
Lookup DateDiff And DateAdd in Books-On-Line.



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
jararaca
you can try

select mydatacolumn from mytable where mydate < getdate() -180


180 is approx 6 months * 30 days
 
select * from <table>
where datediff(mm, getdate(), <datecol>) = 6

Jim
 
Thanks both. I will try that, Dashley. Can anyone please tell me how to access books-on-line? Or just give me the syntax for DateDiff and/or DateAdd if it's not too much trouble.

Thanks.
 
Thanks jbenson001! I'll give it a try.
 
Books On Line is part of the sql server installation. It should show up on your start menu -> all programs -> Microsoft SQL Server menu
 
For the internet version of books on line, see this faq's

faq183-689

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top