3
   

Convert Unix-timestamp to MS Access Date/Time field.

 
 
Reply Sat 11 Mar, 2006 03:18 pm
I'm looking for code that will allow me to store a date in a table as a Unix-Timestamp, but display it and edit it in an MS Access form as human readable Date/Time.

Any help would be apreciated.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 3 • Views: 25,089 • Replies: 11
No top replies

 
DrewDad
 
  1  
Reply Mon 13 Mar, 2006 08:23 am
If I recall correctly, MS Access stores time fields as Julian dates. What format does Unix-Timestamp use?
0 Replies
 
roverroad
 
  1  
Reply Mon 13 Mar, 2006 08:45 am
DrewDad wrote:
If I recall correctly, MS Access stores time fields as Julian dates. What format does Unix-Timestamp use?


I guess it would have to be an unbound field with code behind it to convert to the unix date.

A Unix time stamp is seconds since '1970-01-01 00:00:00' UTC. For example, the time and date of 3/12/2006, 7:47:13 would be "1142149633".

This PHPBB (Able2Know) message board stores all of it's date and times in Unix-Timestamp.
0 Replies
 
DrewDad
 
  1  
Reply Mon 13 Mar, 2006 09:50 am
Quote:
Julian dates (abbreviated JD) are simply a continuous count of days and fractions since noon Universal Time on January 1, 4713 BCE (on the Julian calendar). Almost 2.5 million days have transpired since this date.


It should be straight-forward to convert from Julian to Unix-Timestamp.

Subtract the Julian date of 1/1/1970 00:00:00 from your stored date. Then convert the result to seconds. (Multiply the result by 86400, the number of seconds in one day.)
0 Replies
 
DrewDad
 
  1  
Reply Mon 13 Mar, 2006 09:51 am
And don't forget to adjust for the time zone.
0 Replies
 
roverroad
 
  1  
Reply Mon 13 Mar, 2006 09:27 pm
True, that part is just a matter of mathematics. I'm having trouble with the syntax though. I'm not familiar with programming in Access. I suppose I will have to take some tutorials. I was hoping someone would just magically poop out the code for me. :wink:
0 Replies
 
timwoolfson
 
  1  
Reply Sat 15 Dec, 2007 12:07 pm
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")


Hope the readers of this thread find this post helpful.

I think of got this straight but obviously use at your own risk :-)

Tim Woolfson
EDIT: MODERATOR: DO NOT POST YOUR LINKS HERE
roverroad
 
  1  
Reply Mon 17 Dec, 2007 07:55 am
Well, I've long since figured this problem out, but thanks for the reply.
0 Replies
 
kgordo
 
  1  
Reply Thu 6 Mar, 2008 02:36 pm
I'm just a visiting stranger, but I found this very helpful. It's exactly the answer I came looking for...
0 Replies
 
Danyman
 
  1  
Reply Thu 8 Oct, 2009 07:21 am
thank you for the helpfull formula.
Danyman_de (GER)
0 Replies
 
janetlockett
 
  1  
Reply Fri 9 Oct, 2009 02:11 pm
@timwoolfson,
You solved me millions of headaches. THANK YOU!!!!!
0 Replies
 
tony1120
 
  1  
Reply Tue 16 Nov, 2010 11:34 pm
@timwoolfson,
btw,Microsoft's date value for the beginning of the unix era '1970-01-01 08:00:00' is what?
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
PHP and SWIG - Question by gungasnake
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » Convert Unix-timestamp to MS Access Date/Time field.
Copyright © 2014 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.07 seconds on 04/24/2014 at 10:10:00