If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Timestamp / Datetime Default Values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-22-05, 07:55
stscrc stscrc is offline
Registered User
 
Join Date: Oct 2004
Posts: 13
Timestamp / Datetime Default Values

We recently upgraded from SQL Server to MySQL 5.0 and things have been great except for the way MySQL handels default timestamp fields. In our DB, we have many tables with 2 fields: ModifiedDate and CreatedDate. In the conversion process these fields came across as DateTime fields, but I have no opposition to changing them to TimeStamp fields if I can get the behavior I want.

In SQL Server both fields were defined with default = getdate() so when a new record was inserted the current date and time was put into the fields (I don't care if they're a couple nano-seconds off). When I updated a record, I had to make the code update the ModifiedDate. I can't seem to get this behavior w/ MySQL (we have a ton of code I don't want to have to go and change). Seems MySQL wants to update timestamp fields with the current time every time the record is updated (not ideal for CreatedDate). I just want the defaults to be entered when the record is created and I'll take it from there. Any idea how I can do this?

One other issue is that the DB I want to do this on is already in production, so it would be extremely painful to have to create new tables. I would like to just update the existing tables if at all possible.

Thanks,
Mark
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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