www.webdeveloper.com
Results 1 to 4 of 4

Thread: Fetching Data by Date from mysql

  1. #1
    Join Date
    Feb 2012
    Posts
    3

    Fetching Data by Date from mysql

    Hi,
    I have mysql db that has date in string format. Now I want to fetch data month wise. What would be the mysql to fetch data.

    Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,335
    First suggestion would be to store your dates as DATE or DATETIME (or possibly TIMESTAMP) types in the database, making things much, much easier. If for some reason that is not feasible -- and you better have a really good reason that I frankly can't imagine -- then you would probably have to make use of MySQL's STR_TO_DATE() function to convert on the fly, then use the result as needed, perhaps in a BETWEEN statement.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Feb 2012
    Posts
    3
    Thanks a lot, It works for me

    Thanks,
    modern computers

  4. #4
    Join Date
    Feb 2012
    Posts
    3
    The correct function of mysql is ORDER BY FROM_UNIXTIME(date_in_string_format) ASC

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles