Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    159

    Unanswered: syntax for shift times

    can someone give me the syntax for extracting the shift time from the time
    eg if time is Between #7:00:00 AM# And #3:00:00 PM# then one shift and
    Between #3:00:00 PM# And #11:00:00 PM# then another shift?
    I have times of incidents that I want to determine which shift they occourred on.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select iif(hour(datetimecol) >= 7
           and hour(datetimecol) < 15 
              , 'shift 1',
           iif(hour(datetimecol) >= 15
           and hour(datetimecol) < 23 
              , 'shift 2', 
                'shift 3')) as shift
      from yourtable
    Edit: changed > to >=
    Last edited by r937; 09-01-04 at 19:03.
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2004
    Posts
    159

    Thanks

    Thanks that works for me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •