|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
query based on time
i am writing a query for fetching record of service centers which will be open during the time entered by the user. the opening hour and closing hour of service center are in 24 hour clock. the exact problem is that there are certain centers where the "opening hours" is greater than the "closing hours":so the easy logic of [ entered >"opening hours" and <"closing hours"]
does not work. can anybody suggest me the way to do it. |
|
#2
|
|||
|
|||
|
POst the SQL you have that isn't working
S- |
|
#3
|
|||
|
|||
|
In the query designer I set up a calculated field to seperate those stores which are open past midnight.
Expr1: IIf([ShopHours]![Closing Time]>[ShopHours]![OpenningTime],False,True) Then the query is done with criteria set as follows. Expr1 = False AND after openning hours AND before openning hours OR Expr1 = True AND after openning hours OR Expr1 = True AND before closing hours I used the Time() function to get the current time. The resulting SQL statement was SELECT ShopHours.ShopName, ShopHours.OpenningTime, ShopHours.[Closing Time] FROM ShopHours WHERE (((ShopHours.OpenningTime)<Time()) AND ((ShopHours.[Closing Time])>Time()) AND ((IIf([ShopHours]![Closing Time]>[ShopHours]![OpenningTime],False,True))=False)) OR (((ShopHours.OpenningTime)<Time()) AND ((IIf([ShopHours]![Closing Time]>[ShopHours]![OpenningTime],False,True))=True)) OR (((ShopHours.[Closing Time])>Time()) AND ((IIf([ShopHours]![Closing Time]>[ShopHours]![OpenningTime],False,True))=True)); |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > query based on time |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|