Reputation: 899
WOW... Using MySQL, is there a way to replace the third "-" from the left in the following timestamp:
2012-06-05-23:48:10
You'd think after an hour of searching I would have found something..
Upvotes: 0
Views: 139
Reputation: 5131
MySQL is a relational database management system; it's not for manipulating data.
Instead you would use a programing or scripting language like php to query the database, pull the data into a string, change it, and update the databse. Edit: I'm told that this is possible, but as another user stated there's no direct solution in pure MySQL.
Upvotes: -1
Reputation: 61
For this, it makes more sense for the data to be saved using the standard but given back as the way your application would use it. This post explains what you are looking for.
Upvotes: 0
Reputation: 449783
The literal replace operation that you describe is probably beyond the abilities of pure mySQL - it has regex capabilities, but only for matching.
However, one workaround comes to mind:
Convert the field into a DATETIME field using STR_TO_DATE()
then output it using a custom format using DATE_FORMAT()
that said, storing the date as a native DATETIME
field in the first place would be a good idea anyway.
Upvotes: 4