Groups | Blog | Home
all groups > sql server new users > september 2006 >

sql server new users : Question on query



Alejandro
9/20/2006 10:49:05 AM
I have the following query:

Select convert(char(8), loginstartime, 108) as startime, convert(char(8),
loginendtime, 108) as endtime from userlogin

It returns two values:

startime = 08:00:00
endtime = 18:30:00

Right now it is 10:40 am

If I add a where clause I get no results when in fact I should still get
this record, the clause is:

Select convert(char(8), loginstartime, 108) as startime, convert(char(8),
loginendtime, 108) as endtime from userlogin
WHERE convert(char(8), loginstartime, 108) < getdate() and getdate () <
convert(char(8), loginendtime, 108)


8:00 am is < than 10:40 am .. if I cut the sql here I DO get the results,
but If I add the end date part of the SQL I get no results, when in fact
10:40:00 is < than 18:30:00

what am I missing ? Should I also convert the getdate() function ? If so how
?

A

Alejandro
9/20/2006 10:59:17 AM
Got this one, converted getdate() and it worked.

[quoted text, click to view]

AddThis Social Bookmark Button