Vassago
Former Staff Turned AWF Retiree
- Local time
- Today, 14:48
- Joined
- Dec 26, 2002
- Messages
- 4,748
Hello,
I have a query I need to run that will check a table with a datetime field with various dates and times. I need it to make a field a 1 if the time shown regardless of the date falls between 8:00:00 am and 12:00:00 pm. I need another field to show as 1 If it the time is between 12:00:01pm and 5:00:00pm and another one between 5:00:01pm and 11:00:00pm. I tried the following query, but the results are not calculating correctly. Can someone give me a hand?
SELECT tbl_termcodes.DLListName, tbl_termcodes.DLList, tbl_termcodes.Account, IIf(Format([Calltime],"hh:nn:ss") Between #12/30/1899 8:0:0# And #12/30/1899 12:0:0#,1,0) AS [8-12], IIf(Format([Calltime],"hh:nn:ss") Between #12/30/1899 12:0:0# And #12/30/1899 17:0:0#,1,0) AS [12-5], IIf(Format([Calltime],"hh:nn:ss") Between #12/30/1899 17:0:0# And #12/30/1899 23:0:0#,1,0) AS [5-11]
FROM tbl_termcodes;
Thanks!
Vassago
I have a query I need to run that will check a table with a datetime field with various dates and times. I need it to make a field a 1 if the time shown regardless of the date falls between 8:00:00 am and 12:00:00 pm. I need another field to show as 1 If it the time is between 12:00:01pm and 5:00:00pm and another one between 5:00:01pm and 11:00:00pm. I tried the following query, but the results are not calculating correctly. Can someone give me a hand?
SELECT tbl_termcodes.DLListName, tbl_termcodes.DLList, tbl_termcodes.Account, IIf(Format([Calltime],"hh:nn:ss") Between #12/30/1899 8:0:0# And #12/30/1899 12:0:0#,1,0) AS [8-12], IIf(Format([Calltime],"hh:nn:ss") Between #12/30/1899 12:0:0# And #12/30/1899 17:0:0#,1,0) AS [12-5], IIf(Format([Calltime],"hh:nn:ss") Between #12/30/1899 17:0:0# And #12/30/1899 23:0:0#,1,0) AS [5-11]
FROM tbl_termcodes;
Thanks!
Vassago