SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    St. Paul
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    day in where clause

    Hi,
    I'm using an access DB and ASP and I am trying to create a query that will select all the records except those with date and times on the weekends or that are between 7pm and 3am on weekdays.

    How would I do this? Thank you for your help.
    Ryan

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    well, first of all you have to define what your weekend days are

    if you go with the default, they are 1=sun and 7=sat

    then you want to have the time only between 3am and 7pm, and that's easy if you use a 24-hour clock

    Code:
    select foo, bar
      from yourtable
     where datepart("w",datecolumn) between 2 and 6
       and datepart("h",datecolumn) between 3 and 19
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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