LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Changing date format in MySQL table (https://www.linuxquestions.org/questions/linux-software-2/changing-date-format-in-mysql-table-86498/)

vous 08-28-2003 02:31 AM

Changing date format in MySQL table
 
Hello All,

I have a Bugzilla installation that uses MySQL DB (of course). The date tables in MySQL currently have the following format:

mm-dd-yyyy

We would like to change it to:

dd/mm/yyyy

Would anybody know a quick hack for this?

nephilim 08-28-2003 02:42 AM

You can always change the format in your query like this:

SELECT DATE_FORMAT(thedatetime,'%d/%m/%y %H:%i:%s') FROM ...

I don't know if it's possible to change the format mysql uses by default.

vous 08-28-2003 02:58 AM

Does MySQL have a set format or do you set it when you create the table?

By the way, does MySQL have a history file or log file somewhere where I can check the sql statements to see how that table was created?

nephilim 08-28-2003 03:13 AM

I'm guessing that you can't change the internal MySQL date format because if you do, all the date functions will return wrong results. But I'm not sure about that.

I always create my tables by using a script file so that I still know what I've done later on. If you don't have such a script, you can always do some reverse engineering to generate one. There are several tools to do this, check out http://www.datanamic.com/ to see if they have any tools to help you out.

vous 08-28-2003 03:19 AM

On the logging question, I have read in MySQL docs that indeed it does have a query log file, BUT it is not default and you have to flag it on start in order for it to work :-( ...but again any ideas are welcome :-)

On the reverse engineering, even though it sounds cool, we are a bit strapped for time, but if we get an extension I'll definitley check it out....this is not the only issue we friction with.

I'll keep on looking to see what I can find on changing the date format in the table itself....



nephilim 08-28-2003 03:39 AM

Good luck, and let me know if you find anything!

vous 08-28-2003 04:42 AM

Thanks and I will!

buttersoft 09-03-2003 05:40 AM

I am using the excellent EMS MySQL Manager here in the field management you can easily change the date format no problems.

http://www.ems-hitech.com/index.phtml

Brilliant software.

Also according to previous posting above:-

SELECT DATE_FORMAT(dated,'%d/%m/%y') FROM info;

This works fine on my system.




nephilim 09-03-2003 06:30 AM

Quote:

I am using the excellent EMS MySQL Manager here in the field management you can easily change the date format no problems.
Although this software changes the date format at presentation level, the format in the database stays the same.


All times are GMT -5. The time now is 10:48 PM.