September 15, 2008 at 6:41 am
Hi
I have RegDateTime column of DateTime datatype.
which is storing registration date time of user.
I want to display all users that are registered within 24 hrs.
This should work for AM and PM
How to write query for this?
Thanks in advance.
September 15, 2008 at 6:45 am
HI There,
Could you show us what you have so far.
HINT:
This is going to require a where clause with the GETDATE() function in it
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
September 15, 2008 at 6:53 am
I am using this :
select * from users
where regdatetime > Dateadd(hour,-24,getdate())
Will this give correct result :
if suppose user registers at 11 pm of 15 sep
and if I see the result at 01 am of 16 sep
September 15, 2008 at 6:56 am
That looks good.
Prob a good idea to also do some testing with different examples with different times that are greater, less and equal to your getdate value.
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply