Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Dates and Times Pulled Into Access As Long Integer? 1

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
US
How can I convert the Long Integers given from a MySQL database to datetime values in Access?

Here are some examples of real values I'm getting back:

1233060995
1233060885
1233062676
1233060885

Each line a value for a different record.

Is it stored in a totally different format? I can't think of what it's called, but seems it started with a J. I've not needed to even think about that one for several years now..

Thanks for any suggestions/advice/examples/references

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Okay, I found an answer here:

It's a forum thread, and the specific bit of help is this:
ForumThread said:
Hello anyone who landed on this forum thread:

Unix Time Stamp records seconds since '1970-01-01 00:00:00'

Microsoft store a number representing the number of complete days since '1970-01-00 00:00:00' i.e. 1 = '1970-01-01 00:00:00'

So, Microsoft's date value for the beginning of the unix era '1970-01-01 00:00:00' is 25569

The number of seconds in 25569 days is:
25569*24*60*60
= 2209161600

The number of seconds in 1 day is:
24*60*60
= 86400
So in Access:
Code:
HumanDate: Format(([unixdate]+2209161600)/86400,"dd/mm/yy hh:nn:ss")

Only difference for me is I'd change the dd/mm to mm/dd, since that's what I'm primarily accustomed to.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 



Steve,

If that is true, then will return a date
Code:
dim d as date
d = ([unixdate]+2209161600)/86400
FORMAT converts a date to a STRING...
Code:
di8m s as string
s = Format(([unixdate]+2209161600)/86400,"dd/mm/yy hh:nn:ss")



Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks, I'll take a look into that. The other worked for what I needed, but I'll see how that one does as well. It'll be later this evening or another evening, as it's something I'm piddling with at home. Thanks for the note.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Thanks, I finally just verified your statements, Skip. I don't know yet for sure which format I'll end up needing. I think I may use the text format initially just for viewing, and then I may take the conversion out of the picture altogether, b/c basically, I'm going to export all this data after I've regrouped it all into a CSV file, into a new MySQL database. It's going from an old copy of a website into a new copy of the same site (Drupal 6 to Drupal 7 - both using MySQL as the database).

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Eek! I just realized that this calculation is mostly[/] correct, but it is somehow adding 5 hours to the time of the calculation.

So if anyone has a suggestion on where to change it, that'd be great. I'll see if I can figure it out in the mean time. I guess I need to see how much an hour is in the calculation, and then reduce it by that times 5...

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
And oops... I left an i out of the tgml. [sad]

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Okay, never mind on the last bit. I just used the DateAdd function in the access query to drop off 5 hours, and that corrected it.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top