#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    10
    Rep Power
    0
    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.

    please help


    -Honky
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    81
    Rep Power
    15
    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')
    FROM tableName
    [/code]

    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).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    10
    Rep Power
    0
    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


  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    10
    Rep Power
    0
    nevermind, I got it


    thanks man

Similar Threads

  1. quick mysql/php question
    By mirthika in forum PHP Development
    Replies: 2
    Last Post: February 16th, 2004, 02:15 PM
  2. Quick regex wildcard question.
    By s200 in forum PHP Development
    Replies: 2
    Last Post: February 12th, 2004, 09:09 AM
  3. Quick CSS question
    By ace2600 in forum CSS Help
    Replies: 7
    Last Post: January 16th, 2004, 12:21 PM
  4. JList quick question...
    By cram81 in forum Java Help
    Replies: 4
    Last Post: January 5th, 2004, 07:37 PM
  5. quick question
    By muratisik in forum HTML Programming
    Replies: 7
    Last Post: December 4th, 2003, 07:59 AM

IMN logo majestic logo threadwatch logo seochat tools logo