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

data for six months

Status
Not open for further replies.

simma

Programmer
Sep 11, 2001
398
US
Hello,
How do we get data for six months from today.
Do we use datediff function?
Thanks
 
you can use a between function, something like the following should work.

Code:
Select
Column1,
Column2
From MyTable
Where DateColumn Between DateAdd(mm,-6,GetDate()) and GetDate()

one Note is that the above does not exclude the Time portion of the date from the comparison. To do that you would nee to Cast(Convert(varchar,DateColumn,101) as dateTime) and do the same arourn the GetDate() calls.

The cast convert does have some overhead but I have used it with extremely large data sets and it seems to be minimal.

Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top