Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Testing between dates

Author  Topic 

siasfouche
Starting Member

5 Posts

Posted - 2009-02-02 : 09:28:51
Hi.

where to_date(substr(Test_date, 11, 06),'hh24:mi') between to_date(START_TIME,'hh24:mi') and to_date(END_TIME,'hh24:mi')

I use the above query to test if the test_date falls in a particular shift. (Test_date has milliseconds thats why the conversion looks funny)

Shifts run from 07:00 - 15:00; 15:00 - 23:00 and 23:00 - 07:00.
If works ok except for the shift 23:00 to 07:00 which returns no results which kind off makes sense. I suspect it is because the endtime is larger than the start time. Is there any way around this?

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-02 : 09:33:30
Are you using ORACLE or Microsoft SQL Server?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-02 : 09:33:59
are you using oracle? this is ms sql server forum.you may be better off posting this on oracle forums in www.dbforums.com
Go to Top of Page

siasfouche
Starting Member

5 Posts

Posted - 2009-02-03 : 01:24:28
Thanks.
Go to Top of Page
   

- Advertisement -