Print Page | Close Window

Convert integer to datetime

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6177
Printed Date: 04 May 2024 at 5:26am


Topic: Convert integer to datetime
Posted By: scotjer
Subject: Convert integer to datetime
Date Posted: 24 Apr 2009 at 1:57am
Hi guys,

I wonder if somebody can help me.
I have a "modified date time" field in a database, the value is 609066016. I've been unable to convert that into a datetime, although the fieldname suggests it is one.
I believe the number means 20/04/09 13:57:01.
Any idea how to convert the integer to datetime with a formula in CR2008?

Thanks in advance!
scotjer



Replies:
Posted By: scotjer
Date Posted: 24 Apr 2009 at 8:31am
ok, found a solution. If anybody is looking for a similiar solution:

CDate (({PROBLEMS.MODIFY_DATETIME}/(24*60*60))+2 +(Date (1990, 1, 1)-Date (1900, 1, 1)))

Im my case the base date was 01/01/1990 and I had to add the +2 to correct the date.


Posted By: DBlank
Date Posted: 24 Apr 2009 at 8:42am
Is this unix time?
if so:
dateadd("s",tonumber( mailto:%7b@609066016%7d%29,datetime%281970,1,1,0,0,0 - {table.timefield}),datetime(1970,1,1,0,0,0 ))
 
your sample item of 609066016 would end up as:
4/20/1989   9:00:16AM
If not, you would need to figure out what the start point is for the time and make sure this is total # of seconds then adjust the formula part of "datetime(1970,1,1,0,0,0))" for the true start time.



Print Page | Close Window