Jump to content

Recommended Posts

Hey guys,

 

First of all, thanks for reading my post, its much appreciated.

 

I've been roped into trying to develop a system to work with a large CSV file, which I believe should be ported into a mysql db to start off with then processed via php.

 

The only issue comes into searching through the DB and finding a specific date range, I am trying to use the mysql between code such as this:

 

SELECT * FROM sample WHERE `order_date` >= "01/01/2010" and `order_date` < "30/12/2010"

 

But I still get order_date's that are outside of that date range.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/272311-help-with-mysql-select-betweenwhere/
Share on other sites

Re-import it using MySQL's STR_TO_DATE() function to get the date in the right format,

add a new field and UPDATE the date into the new field with STR_TO_DATE()in the proper format and use that field for the comparisons,

or use STR_TO_DATE() on the values in your comparisons.

I imagine a pain in my processor's arse to change through code

 

It would be a total of one UPDATE query, without a WHERE clause, to convert the existing value and set a new column to the corresponding YYYY-MM-DD value, all at once.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.