|
-
Oct 5th, 2000, 06:33 AM
#1
Thread Starter
Addicted Member
Hi,
I need to return a recordset from a table where records are from the last 24 hours. Currenty in a Stored Procedure I have Select .... where [DateTime] > GetDate() -1 which seemed to work quite well until today when it has suddenly been throwing up records from September .
If anybody has any ideas on a better way of doing this then any help would be appreciated.
Cheers
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Oct 5th, 2000, 08:03 AM
#2
Fanatic Member
Hi S@NSIS
You can use the datediff function to do what you ask
SELECT field1, field2
FROM Table1
WHERE DATEDIFF(hh,field1,GETDATE()) <= 24
GETDATE() is the SQL equivelant of vb's Now()
hope this helps
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Oct 5th, 2000, 09:25 AM
#3
Thread Starter
Addicted Member
LOL
Cheers Ian but my code was alright after all. A combination of two many beers last night and American date formats totally confused me this morning!! 
Thanks anyway
Shaun
Web/Application Developer
VB6 Ent (SP5), Win 2000,SQL Server 2000
-
Oct 5th, 2000, 09:30 AM
#4
Fanatic Member
it is a bastard tring to program with a hangover from hell, done it enough times myself with some stupid little thing that I couldn't comprehend as I was still pissed from the night before
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|