Date format change

How to change date format dd/mm/yyyy to dd-mm-yyyy using mysql update query

You don’t need to - mysql will store the date format in it’s own format relative to UTC time. What you’ll want to do is change the format returned in the SELECT query.

Actually don’t save your dates as either. In order to save them in either format you would be using varchar or char field. you would thus lose the ability to use any date functions on the field.

Save them as DATE type and store them as yyyymmdd and then use DATE_FORMAT to display them in the way you want them. If you already have them as dd/mm/yyyy then create a new column of the type DATE and use STR_TO_DATE to reformat them correctly as yyyymmdd in the new column and then delete the old column.


I’m using datatype varchar

That may be good enough if all you ever want to do is look at the stored value.

But if you want to do things like sort, find ranges, find future / past intervals etc. you really want to use one of the Date and Time Types

This is not my issue .i want to change / to -

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.