MySQL Forums
Forum List  »  Newbie

Re: Filtering Entries by Complex Date
Posted by: Christopher Esbrandt
Date: November 04, 2014 06:00PM

The only change had been to the CASE WHEN END from what I originally posted:

SELECT needDate FROM courses WHERE CASE WHEN needDate IS NULL THEN '20120101' WHEN CHAR_LENGTH(needDate) > 6 THEN DATE_FORMAT(STR_TO_DATE(needDate, '%m/%d/%Y'), '%Y%m%d') WHEN CHAR_LENGTH(needDate) > 4 THEN DATE_FORMAT(STR_TO_DATE(needDate, '%Y%m'), '%Y%m01') ELSE DATE_FORMAT(STR_TO_DATE(needDate, '%Y'), '%Y0101') END BETWEEN DATE_FORMAT(STR_TO_DATE('11/29/2013', '%m/%d/%Y'), '%Y%m%d') AND DATE_FORMAT(STR_TO_DATE('06/17/2014', '%m/%d/%Y'), '%Y%m%d');

That's the latest attempt with the updated CASE...WHEN...END and trying to format it in a manner where it should be easily sortable.

Options: ReplyQuote


Subject
Written By
Posted
Re: Filtering Entries by Complex Date
November 04, 2014 06:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.