Hi all
I am very new to SQL and trying to select some records from a M/S
SQL database to display 7 days worth of data
My date column is set as a small date UK format
15/10/2002 00:33:13
Would I use the commands something like this
Select *
From my database
Where my table between GETDATE () AND GETDATE ()-7
Can anybody help as i am real lostohhh found it
SELECT Whatever, WhateverElse FROM TableName WHERE DateField >= DATEADD(d, -7, GETDATE())
Originally posted by webstep
Hi all
I am very new to SQL and trying to select some records from a M/S
SQL database to display 7 days worth of data
My date column is set as a small date UK format
15/10/2002 00:33:13
Would I use the commands something like this
Select *
From my database
Where my table between GETDATE () AND GETDATE ()-7
Can anybody help as i am real lost|||If you put this at the top of your script:
declare @.date1 datetime, @.date2 datetime
set @.date2 = convert(varchar(11), getdate(), 111)
set @.date1 = convert(varchar(11), getdate()-7, 111)
...then you can just use @.date1 as your from date and @.date2 as your to date. You won't have to put in any dates.
Steve
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment