Re: Changing a field's data in every record
- Date: Sun, 19 Feb 2017 11:53:42 +0100
- From: Reindl Harald <h.reindl@xxxxxxxxxxxxx>
- Subject: Re: Changing a field's data in every record
Am 19.02.2017 um 11:11 schrieb Peter Brawley:
On 2/18/2017 15:13, debt wrote:
I’ve been asked to post a question here for a friend.
Is there a formula to change the format of the data in a single
field in every record of a table? She has a "timestamp” in a text
field formatted as 2017|02|16|04|58|42 and she wants to convert it to
a more human readable format like 2017-02-16 @ 04:58:42
How does one "grab" the existing data and then change it?
If it's a timestamp, it's saved as 2017-02-16 04:58:42, not as you
showed it, and there's no need to change it, indeed she couldn't.
Instead, in a query that retrieves the timestamp, use the mysql
date_format() function to format the timestamp as desired.
you missed the quotes around timestamp as well as "in a text field
formatted" and so THERE IS a need to change it - please consider to read
as i read the post i hoped someone will say it nicer in between:
*nobody* right in his mind saves timestamps in a "human readable format"
but as a unix timestamp or date with the correct field type
unix timestamps have the advantage that they can be also in PHP simple
compared with <>, < and > because it#s just the seconds since 1970-01-0-1
since this is nothing but random text you just need to select the data,
split them, chnage the filed type, write them back and replace the
direct output with strftime()
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql