mySQL date functions: dayname -> number

Discussion in 'OT Technology' started by Slid., Nov 15, 2006.

  1. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    mySQL:

    So I have these daynames, Monday, Tuesday, etc. but I want to convert them to a number so I can compare. You can't do SELECT 'Monday' - 'Tuesday' but if I could turn 'Monday' into a 2 and 'Tuesday' into a 3 then I could. Oh, and I have no correponding full-date to go with the daynames.

    Any ideas?
     
  2. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    I need some way to compare and order based off a DAYNAME number. I have a thing that will give you an estimated ship date based off a truck schedule that is different Monday - Friday.

    So I want to say "what's the difference between TODAY [CURDATE()] and the truck schedule [Monday-Friday]" then order based off the difference.
     
  3. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    Without doing it through a query I see myself grabbing all available daynames then passing it through an array in PHP to convert Monday->2, Tuesday->3, etc. and base my calculation there. I'd like to get as much done inside the query as I can.
     

Share This Page