Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Aug 2005
    Location
    United Kingdom
    Posts
    38
    Member #
    11128
    I am storing datetime in the format 0000-00-00 00:00:00 in MySQL and I want to select records from the table with a date range given in the query. I did it by using "Select * from Table where Date > startdate and Date < enddate " but it does not work when you select different YEAR for start and end date range. How to fix it ?

    -----------------------------------------
    http://www.binarytrends.com

  2.  

  3. #2
    Senior Member
    Join Date
    Jul 2005
    Location
    S.Wales, UK
    Posts
    250
    Member #
    10742
    MySQL stores dates as yyyy-mm-dd

    Make sure the date you are comparing it to is in the correct format. It should work.
    Paul Creedy
    Visit my community site at: www.rhonddacynontaff.com
    My hosting: www.rcthosting.com
    My Content Management product: www.dynamiccontenteditor.com

  4. #3
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Be sure to quote mark your date values.

    These work:
    Code:
    SELECT * FROM tbl_name where date between '1961' and '1989'
    SELECT * FROM tbl_name where date between '1961-02-27' and '1989-06-21'
    SELECT * FROM tbl_name where date > '1961' and date < '1989-05-15'
    S. Rosland


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:41 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com