dbTalk Databases Forums  

Re: Simple query time compare problem?!

microsoft.public.sqlserver.mseq microsoft.public.sqlserver.mseq


Discuss Re: Simple query time compare problem?! in the microsoft.public.sqlserver.mseq forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Vishal Parkar
 
Posts: n/a

Default Re: Simple query time compare problem?! - 08-07-2003 , 06:06 AM






See following example:
note: you will have to make use of CONVERT function.
Ex:
create table #t(code int, endtime varchar(500))

insert into #t select 1 ,'08:00:00' union all
select 2 ,'23:59:59' union all
select 3 ,'15:22:23'


select * from #t
where convert(datetime, endtime,108) > '15:00:00'

--
-Vishal

"JJ" <digi123 (AT) mail2me (DOT) com.au> wrote

Example Table:

Code EndTime
1 08:00:00
2 23:59:59
3 15:22:23

Why after " SELECT * from Table WHERE ( EndTime>'15:00:00' ) " query statement, it never return any result?!
Does the query statement needs more correction?!

------------------------------------------------------------------------------

Please help. MANY THANKS in advance
JJ


Reply With Quote
  #2  
Old   
JJ
 
Posts: n/a

Default Re: Simple query time compare problem?! - 08-07-2003 , 09:30 PM






First, thank you for your reply.


No. Originally, the field 'EndTime' is already created in 'Datetime' table data type (not in varchar)


My problem is how to query for the right rows with eg. Endtime>'15:00:00'. I've tried with the SELECT statement.
But the returning result is - it doesn't return any thing at all ?! Couldn't we compare directly with 'datetime' field(without any CONVERT function) ? What have I done wrong....?

Please comments.

JJ



"Vishal Parkar" <vgparkar (AT) hotmail (DOT) com> wrote

See following example:
note: you will have to make use of CONVERT function.
Ex:
create table #t(code int, endtime varchar(500))

insert into #t select 1 ,'08:00:00' union all
select 2 ,'23:59:59' union all
select 3 ,'15:22:23'


select * from #t
where convert(datetime, endtime,108) > '15:00:00'

--
-Vishal

"JJ" <digi123 (AT) mail2me (DOT) com.au> wrote

Example Table:

Code EndTime
1 08:00:00
2 23:59:59
3 15:22:23

Why after " SELECT * from Table WHERE ( EndTime>'15:00:00' ) " query statement, it never return any result?!
Does the query statement needs more correction?!

----------------------------------------------------------------------------

Please help. MANY THANKS in advance
JJ


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.