bubblegum.anarchy Posted April 19, 2007 Share Posted April 19, 2007 The str_to_date function is driving me nuts.. working one minute and not working the next (returns null when not supposed to). I have a simple public_holiday table with an `occurs` field of type varchar(255) not null default '1st January'; I have tried all manner of string data types and even setting the field to allow null but the function remains sporatic the query used is: SELECT str_to_date(occurs, '%D %M') FROM public_holiday; #works one day and returns null the next SELECT str_to_date('1st January', '%D %M') from public_holiday; #always works table contains: 1st January 26th January Second Monday March Before I give up on the function completely, does anyone know what might be causing the null returns? Link to comment https://forums.phpfreaks.com/topic/47701-str_to_date-issues/ Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 Well, the 3rd record if your table doesn't match... why do I feel like I've seen this thread before? Link to comment https://forums.phpfreaks.com/topic/47701-str_to_date-issues/#findComment-233953 Share on other sites More sharing options...
bubblegum.anarchy Posted April 20, 2007 Author Share Posted April 20, 2007 This might look similar to a recent thread where I requested a query to translate `Second Monday March`... I expect `Second Monday March` to return null but I do not expect the same result for the 1st Jan and 26th Jan... anyways.. I have totally flagged the str_to_date function... now the values are being converted in php first since there are not many public holiday dates and I can apply the array in static form to a query using IN (). Link to comment https://forums.phpfreaks.com/topic/47701-str_to_date-issues/#findComment-234343 Share on other sites More sharing options...
fenway Posted April 22, 2007 Share Posted April 22, 2007 So you're happy with this "solution"? Link to comment https://forums.phpfreaks.com/topic/47701-str_to_date-issues/#findComment-235353 Share on other sites More sharing options...
bubblegum.anarchy Posted April 23, 2007 Author Share Posted April 23, 2007 you can certainly lock this thread but no solution... just alternate path. Link to comment https://forums.phpfreaks.com/topic/47701-str_to_date-issues/#findComment-235634 Share on other sites More sharing options...
Recommended Posts