MySQL Forums
Forum List  »  Newbie

Re: How do I create rows from an array to create a view in phpMy Admin - mySql
Posted by: Jon Stephens
Date: December 09, 2021 07:55AM

And now it occurs to me that you can cast the date columns to the DATE type when creating the view:

    post_id                             AS Post,
    Meta_key                            AS MKey,
    CAST(LEFT(Meta_Value, 10) AS DATE)  AS StartDate,
    CAST(RIGHT(Meta_Value, 10) AS DATE) AS EndDate
  FROM mytable;

(Sorry for my typo in the earlier example. It would be nice if whoever created the original table had been consistent with letter-casing.)

Now StartDate and EndDate are DATE values with which you can use MySQL's date functions.


Jon Stephens
MySQL Documentation Team @ Oracle
Orlando, Florida, USA

MySQL Dev Zone
MySQL Server Documentation

Options: ReplyQuote

Sorry, only registered users may post in this forum.

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.