Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Read/Write TimeStamp In Seconds from Certain Date

Posted on 2007-08-01
3
Medium Priority
?
152 Views
Last Modified: 2010-04-30
I have software that writes a time stamp in seconds starting from the date 01/01/1970 00:00:00
Example this is the Date 07/31/2007 16:44:44 and the TimeStamp is 1185900284
The time stamp is the seconds that have passed from the date above, I'm trying to figure out how to read the time stamp to get the date and read the date to get the time stamp.
0
Comment
Question by:thaburner
3 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 1000 total points
ID: 19608089
Hello thaburner,

MsgBox DateAdd("s", #1 Jan 1970#, TimeStamp)   < --- convert time stamp to date
MsgBox DatDiff("s", #1 Jan 1970#, Now)                 < --- convert date to time stamp

Regards,

Patrick
0
 
LVL 38

Assisted Solution

by:PaulHews
PaulHews earned 1000 total points
ID: 19608098
Option Explicit

Private Sub Command1_Click()
    MsgBox DateFromTimestamp(1185900284)
    MsgBox TimeStampFromDate(DateFromTimestamp(1185900284))
End Sub

Private Function DateFromTimestamp(TimeStamp As Long) As Date
    DateFromTimestamp = DateAdd("s", TimeStamp, #1/1/1970#)
End Function


Private Function TimeStampFromDate(dt As Date) As Long
    TimeStampFromDate = DateDiff("s", #1/1/1970#, dt)
End Function

0
 

Author Comment

by:thaburner
ID: 19608255
That worked perfectly thanks....
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question