MYSQL TIMESTAMP Format - DOS / Linux

This is a discussion on MYSQL TIMESTAMP Format - DOS / Linux within the MySQL Database forums, part of the Database Forums category; Hi, I have a query re' the TIMESTAMP format. I've set up identical tables on my DOS machine (Win....


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-16-2007
janedunnie@gmail.com
 
Posts: n/a
Default MYSQL TIMESTAMP Format - DOS / Linux

Hi,

I have a query re' the TIMESTAMP format.

I've set up identical tables on my DOS machine (Win.XP), and also on
my Linux box. Nothing fancy, just a few fields, two of which are
TIMESTAMP fields. These are set up as follows:

MYDATE1 TIMESTAMP NOT NULL,
MYDATE2 TIMESTAMP

Each table works fine on both the DOS box and the Linux box.

However, on the DOS box the dates are stored without hyphens, but on
the Linux box the dates are stored with hyphens.

eg DOS = 20070508112803
Linux= 2007-05-16 08:32:56

This is a problem because my scripts assume the first format, although
the probem is really that the formats are different - either one I can
live with, just so long as they are the same.

I'm guessing there must be some way to get MySQL to store the
TIMESTAMP field, and for that matter DATE fields, in a certain format,
but I have found nothing to help me so far.

Any information re' resolving this would be gratefully received.

Thanks!
Jane

Reply With Quote
  #2 (permalink)  
Old 05-16-2007
J.O. Aho
 
Posts: n/a
Default Re: MYSQL TIMESTAMP Format - DOS / Linux

janedunnie@gmail.com wrote:

> eg DOS = 20070508112803
> Linux= 2007-05-16 08:32:56
>
> This is a problem because my scripts assume the first format, although
> the probem is really that the formats are different - either one I can
> live with, just so long as they are the same.


Use DATE_FORMAT, that way you will always be sure you get the dates in the
format you want.




--

//Aho
Reply With Quote
  #3 (permalink)  
Old 05-16-2007
janedunnie@gmail.com
 
Posts: n/a
Default Re: MYSQL TIMESTAMP Format - DOS / Linux

Well, thanks for the reply, and I guess from your comment that
DATE_FORMAT would be used when reading from the table. However, there
must still be somewhere in the setup that tells MySQL how to save
dates, etc in certain formats, which is really what I would like to be
able to find out if possible.

Meantime I'll play with DATE_FORMAT and see how that works out.

Thanks!
Jane


Reply With Quote
  #4 (permalink)  
Old 05-16-2007
janedunnie@gmail.com
 
Posts: n/a
Default Re: MYSQL TIMESTAMP Format - DOS / Linux

Ah, just figured out that the var's I need are as follows:

mysql> SHOW VARIABLES LIKE "%format%";

.....
| date_format | %Y-%m-%d |
| datetime_format | %Y-%m-%d %H:%i:%s |
| default_week_format | 0 |
| time_format | %H:%i:%s |
.....

Thanks,
Jane


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:58 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0