Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    nca
    nca is offline
    New Coder
    Join Date
    Dec 2003
    Posts
    39
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Query with 2014 date

    I am completely stumped as to why this query results in no matches:

    PHP Code:
    SELECT STYLIST FROM TIMECLOCK WHERE DATEOFPUNCH <= '01-04-2014' AND DATEOFPUNCH >= '12-29-2013' 
    When there are 3 records in the database table TIMECLOCK that have the DATEOFPUNCH as 12-29-2013. This query has always worked perfectly fine until today is the first time it has a 2014 date... Any ideas?

    It is to find all STYLIST in TIMECLOCK table with a DATEOFPUNCH between 12-29-2013 -> 01-04-2014

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    You sure that the dateofpunch datatype is a datetime or derivative type?
    The format you have here of MM-DD-YYYY is incorrect for a datetime, so its comparing as a string. If its a datetime type, use the proper 2014-01-04 and 2013-12-29 format. If its not a datetime type, you'll need to correct the structure as strings are unreliable for comparisons.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

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