Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-24-2009, 11:50 AM   PM User | #1
butlins
Regular Coder

 
Join Date: Aug 2006
Location: Cardiff, UK
Posts: 141
Thanks: 15
Thanked 2 Times in 2 Posts
butlins is an unknown quantity at this point
Converting dates between MSSQL and MySQL

I've just had my first project which involves migrating a MSSQL database into MySQL, and I've just hit my first puzzler (which I'm hoping is something that anyone who performs these migrations regularly will find trivial).

The dates seem to be stored as the equivalent of a UNIX timestamp - values like 38376.51454 and 39406.75522 - and I've searched both Google and CodingForums.com, but to be honest I'm not sure of the terminology, so I'm not sure if I'm searching for the right thing.

I have MSSQL Server Management Studio 2005, am running MySQL 5.0.41 and have the MySQL GUI Tools (although I've not persuaded the Migration Assistant to work) and Navicat, in case there's anything that I can do when actually migrating the data, rather than transforming it after.

Ideally, I'd like the dates stored as MySQL dates, as that would make it easier for me to continue working with the imported data, and create new entries.

Can anyone point me in the right direction?
__________________
If anyone asks my boss, this counts as work, okay?
butlins is offline   Reply With Quote
Old 06-24-2009, 12:22 PM   PM User | #2
butlins
Regular Coder

 
Join Date: Aug 2006
Location: Cardiff, UK
Posts: 141
Thanks: 15
Thanked 2 Times in 2 Posts
butlins is an unknown quantity at this point
Solved!

I should have persisted a little longer with my search! If anyone else is looking for the answer on how to convert between MSSQL Datetime and Unix Timestamp formats, I found a handy guide here.
__________________
If anyone asks my boss, this counts as work, okay?
butlins is offline   Reply With Quote
Old 06-24-2009, 02:06 PM   PM User | #3
tomws
Senior Coder

 
tomws's Avatar
 
Join Date: Nov 2007
Location: Arkansas
Posts: 2,644
Thanks: 29
Thanked 330 Times in 326 Posts
tomws will become famous soon enoughtomws will become famous soon enough
Not sure if you've tried it out yet, but MySQL has a migration toolkit available for download. Handles data migration automatically if you're just moving data from one db to the other. I've used it for Access-to-MySQL migration.

http://dev.mysql.com/downloads/gui-tools/5.0.html
__________________
Are you a Help Vampire?
tomws is offline   Reply With Quote
Old 06-24-2009, 02:13 PM   PM User | #4
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
Those dates don't look like UNIX TIMESTAMP to me.
guelphdad is offline   Reply With Quote
Old 06-25-2009, 06:21 AM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,201
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
They aren't Unix timestamps: They are actually ODBC DATETIME values, not native SQL Server values. I'm guessing he is getting the data from SQL Server via an ODBC connection of some sort.

They are the number of days since 30 December 1899 expressed as a floating point number. That is, the integer part is the number of days; the fraction is the fraction of 24 hours on the date in question. (e.g., 17.75 would be 17 January 1900 18:00:00)

Those two dates are:
1/24/2005 12:20:56 PM
11/20/2007 6:07:31 PM

(Easy to do in MSIE using VBS code
Code:
<html><body>
<script language="VBScript">
document.write CDATE(39406.75522 ) & "<br>" & CDATE(38376.51454)
</script>
</body></html>
SQL Server uses an entirely different scheme for encoding datetime values. Two integers: First is number of days since 1/1/1900 and second is number of funny units since midnight. If I remember correctly, the funny units are 1/3 of a millisecond, or something like that. It's all in the SQL Server docs, of course.

Last edited by Old Pedant; 06-25-2009 at 06:23 AM..
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
tomws (06-25-2009)
Old 08-21-2009, 01:03 PM   PM User | #6
wonn1377
New to the CF scene

 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
wonn1377 is an unknown quantity at this point
Migrate almost any data

I think u should use a third party help to resolve this problem, i use dbload to solve it when i was migrated my data, it can migrate almost any data, it helps me to convert MSSQL to MYSQL, MS access to MSSQL, mysql, csv loader, foxpro and MSSQL to MS access, MYSQl, CSV, foxpro etc. i found it on google search.


Download Free : http://www.dbload.com
wonn1377 is offline   Reply With Quote
Old 08-31-2009, 10:59 AM   PM User | #7
jean3167
New to the CF scene

 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jean3167 is an unknown quantity at this point
Here is a tool to convert MSSQL to MYSQL database. That i found on google search it this converter can do migrate any data try and tel me is that worth or not.
jean3167 is offline   Reply With Quote
Old 03-03-2010, 01:40 PM   PM User | #8
shumaker212
New to the CF scene

 
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
shumaker212 is an unknown quantity at this point
Quote:
Originally Posted by wonn1377 View Post
I think u should use a third party help to resolve this problem, i use dbload to solve it when i was migrated my data, it can migrate almost any data, it helps me to convert MSSQL to MYSQL, MS access to MSSQL, mysql, csv loader, foxpro and MSSQL to MS access, MYSQl, CSV, foxpro etc. i found it on google search.


Download Free : http://www.dbload.com

Is this work on linux
shumaker212 is offline   Reply With Quote
Reply

Bookmarks

Tags
date, migration, mssql, mysql, timestamp

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:08 PM.


Advertisement
Log in to turn off these ads.