November 15th, 2000, 05:27 PM
How do I use date_format for multiple columns, I know the following query works:
SELECT DATE_FORMAT(columnName,'%d/%m/%Y') FROM tableName
I have like 6 or 7 columns that need to be date_formated, the above only does one. I don't have to use seperate queries do I ?
I've tried various ways to get it working to no avail.
November 15th, 2000, 08:27 PM
Just apply date_format to each of the separate columns -- i.e., for each column you wish to have date formatted, you need to apply the date format procedure. So you're query (I'm doing it for just two columns, not all six -- just extend it up) would be:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
SELECT DATE_FORMAT(columnName1,'%d/%m/%Y'), DATE_FORMAT(columnName2,'%d/%m/%Y')
Of course, if your columns are in separate tables you'll either have to perform a join (only a good idea if they actually need to be joined), or write separate queries (much much faster if a join isn't necessary).
November 16th, 2000, 10:48 AM
I already tried that, it doesn't work.
ERROR 1064: You have an error in your SQL syntax near 'SELECT DATE_FORMAT(requested_resolution_date,'%d/%m/%Y'), DATE_FORMAT(assignedto' at line 2
November 16th, 2000, 10:51 AM
nevermind, I got it