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)
 query in time between operation

Author  Topic 

tyh2003
Starting Member

3 Posts

Posted - 2009-03-02 : 23:57:20
I am currently working on a parking system project, one of the system functions is that when the car arrives terminal, it needs to evaluate whether the arrival time is within the zone opening hours??

for example, parker arrival time is 13:52

zone opening houts is from 9:00 to 23:00

how could it know whether the arrival time is within the zone opening hours?

I have tried several method in sql server express. I found that i could not just enter time (e.g 12:20) for datetime field type, it only accepts yyyy/mm/hh hh:mm:ss format, is it the default format of sql server express?

i really have no idea of how to get it done, anyone could help or give some hints for me??

thks






Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-03-03 : 00:09:36
please see this link:--


http://www.sql-server-helper.com/tips/date-formats.aspx
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-03 : 00:17:45
declare @parkerarrivaltime datetime
select @parkerarrivaltime ='6:52'
select @parkerarrivaltime

if(@parkerarrivaltime between '9:00' and '23:00')
select 'With in time'
else
select 'Time Exceeded'

select case when @parkerarrivaltime between '9:00' and '23:00' then 'With in time' else 'Time Exceeded' end as description
Go to Top of Page
   

- Advertisement -