Hello to all,

Well I have been bangin' my head against the wall on this. I know it is simple but I cannot get the date to format from Mysql
YYYY-MM-DD to MM-DD-YYYY for display in PHP /HTML

Any help is appreciated.

Thanks

Chapa

    SELECT DATE_FORMAT(date, '%m-%d-%Y') as date_formatted FROM table
    

      Originally posted by devinemke

      SELECT DATE_FORMAT(date, '%m-%d-%Y') as date_formatted FROM table
      

      [/B]

      I tried that and it was not converting my date it was giving me just the - - no date data. I have the following query that grabs data from two tables using a join and creates a pseudo table. However I wanted the dateDet formatted to MM-DD-YYYY instead of YYYY-MM-DD. I had inserted the date_format as follows
      DATE_FORMAT(C.datedet, '%m-%d-%Y') as dateDet . I also attempted to insert DATE_FORMAT after the "as" and format dateDet and that still did not work in the following query statement where the C.dateDet as dateDet appears.

      $sql = "select I.PID as PID, I.name as name, I.dob as dob, C.dateDet as dateDet, C.offense as offense";
      $sql .= " from persons as I, offense as C where I.name like \"%$trimmed%\" and I.PID = C.PID ";

      Thanks for the feedback :-)

        I guess the string I was using for the date format was incorrect. I tried the date strings you provided and it worked fine.

        Thanks and have a great weekend!

        Chapa

          Write a Reply...