-
April 13th, 2007, 12:58 PM
#1
Senior Member
Mysql Date Format
Hi guys
There's another one.
I remember finding once how to do it around 2 years ago, unfortunately could not do it now.
I need to change format in which MySQL stores dates to dd-mm-yyyy.
I know that formats can be changed in the queries, but it will be taking up extra cycles on the server, doing it once seems more apropriate, as my server system is SLOW.
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 13th, 2007, 01:10 PM
#2
-
April 13th, 2007, 01:23 PM
#3
Senior Member
Originally Posted by MsMittens
This one is used with Select statement.
And I am looking to change the way MySQL stores dates in the DATE field, from yyyy-mm-dd 00:00:00 to dd-mm-yyyy
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 14th, 2007, 11:53 AM
#4
I don't think that you can do it that way?
My understanding is that the date is actually stored in a standard format (yyyy-mm-dd) and that you can change this with a format or a function to display it?
I could be wrong, but I think that is how more recent versions do it, at least
This may help: http://www.dan.co.uk/mysql-date-format/
-
April 14th, 2007, 11:36 PM
#5
Or don't do it via the select statement and do something like this:
Code:
//some code to get the ResultSet...
Timestamp stamp = results.getTimestamp(3);//or whatever index
Date d = new Date(stamp.getTime());
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
String k = sdf.format(d);
-
April 15th, 2007, 05:46 PM
#6
Senior Member
I guess I'll need to delve in my notes more then 2 years back and see if I can find it there
I have a LOT of notes, it will take a LONG time
I'm going to get fired till I find the answer
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 15th, 2007, 11:32 PM
#7
Hmmm,
I know that formats can be changed in the queries, but it will be taking up extra cycles on the server, doing it once seems more apropriate, as my server system is SLOW.
If that is the case I would say that you have a much bigger problem with your server and database/applications other than the way MySql naturally handles dates.
I would question whether MySql would actually store the date as dd-mm-yyy rather that just do an on the fly conversion when you recall it?
I wonder if you are thinking of Sql Server, which I seem to recall does/did store dates in that format?
There might be something in DBFormat that would help?
-
April 18th, 2007, 11:55 AM
#8
Senior Member
Originally Posted by nihil
Hmmm,
If that is the case I would say that you have a much bigger problem with your server and database/applications other than the way MySql naturally handles dates.
I would question whether MySql would actually store the date as dd-mm-yyy rather that just do an on the fly conversion when you recall it?
I wonder if you are thinking of Sql Server, which I seem to recall does/did store dates in that format?
There might be something in DBFormat that would help?
I'll look in to "DBFormat".
Yet the problem is not within the server itself, but making the aplication as efficient as possible.
As the system is going to be aimed at Europe and might be getting a number of hits it only makes sence to change the format of the dates once, instead of doing it for a hundred users, with a up to 20 - 30 dates. Only that will make it 2000 - 3000 conversions. If the amount of visitors grows and the amount of data expands... I don't think that you need me to do the maths .
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 19th, 2007, 10:11 AM
#9
I don't think you can do it like that. MySQL stores the date in the standard (ISO) format yyyy-mm-dd. You don't have any options to change it (at least, that was always my understanding).
As has been previously stated, your best bet is to convert on entry/retreival by using DATE_FORMAT().
2 links for you...
http://dev.mysql.com/doc/refman/5.0/...functions.html
http://safari.oreilly.com/059652708X...X_CHP_6_SECT_3
\"Clouds are not spheres, mountains are not cones, coastlines are not circles, and bark is not smooth,
nor does lightning travel in a straight line.\" -Benoit Mandelbrot
-
April 19th, 2007, 02:24 PM
#10
I also do not know anyway to store dates differently. You can format the query and that should be all that most people need. That link that nihil works great :-)
Similar Threads
-
By cheyenne1212 in forum Miscellaneous Security Discussions
Replies: 7
Last Post: February 1st, 2012, 02:51 PM
-
By nightcat in forum The Security Tutorials Forum
Replies: 9
Last Post: May 28th, 2005, 02:47 AM
-
By helloworid in forum Newbie Security Questions
Replies: 10
Last Post: April 30th, 2004, 08:27 PM
-
By gore in forum Newbie Security Questions
Replies: 11
Last Post: December 29th, 2003, 08:01 AM
-
By instronics in forum The Security Tutorials Forum
Replies: 7
Last Post: February 5th, 2003, 10:04 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|