Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: format a datetime value field Post Reply Post New Topic
Author Message
Memoli28
Groupie
Groupie
Avatar

Joined: 10 Apr 2009
Online Status: Offline
Posts: 58
Quote Memoli28 Replybullet Topic: format a datetime value field
     Posted: 19 Jun 2009 at 9:51am
Hi all,
 
One field in a table has the following data:(datetime value)
 
906,151,655.55 (something like a transmit number)
 
actually it means: 06/15/2009 16:58:05
 
my question is : what kind of formula do i have to create to get the following format:
 
06/15/2009 16:58:05 (MM/DD/YYYY HH:MM:SS)
 
and the new- field which is created by the formula ( if/then/else) ,will be used in select expert.
 
any help is welcome.
 
regards,
memoli
 
 
 
 
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jun 2009 at 11:02am
most likely that is the number of seconds that has transpired since a specific start date and time. if that is the case you can get the actual datetime value by using the date add function but you will need to know what the start datetime is to get it to work.
dateadd("s",{table.numberfield},startdatetime goes here)
IP IP Logged
Memoli28
Groupie
Groupie
Avatar

Joined: 10 Apr 2009
Online Status: Offline
Posts: 58
Quote Memoli28 Replybullet Posted: 19 Jun 2009 at 11:54am
Hi Dblank,
 
As always,thanks for your reply.
 
i think the startdatetime is 1/1/2000 00:00:00
 
so, the formula would be :
dateadd("s",{table.numberfield},#1/1/2000 00:00:00#) ?
 
Since i am not at work ,i am not able to check it.
 
regards,
Memoli
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jun 2009 at 12:07pm
if my assumption was correct (although I don't know why it has the .55 on the end) and your time value of 906,151,655.55 = 06/15/2009 16:58:05 then the formula of
dateadd("s",-906151655.55,#06/15/2009 16:58:05#)
returns a value of #09-27-1980  8:10:30PM# indicating your formula should be:
dateadd("s",{table.numberfield},#09/27/1980 08:10:30PM#)
 
Again, I am guessing at that initial concept of it being a count of seconds and "09/27/1980 08:10:30PM" does seem to be rather arbitrary begin point...


Edited by DBlank - 19 Jun 2009 at 12:09pm
IP IP Logged
Memoli28
Groupie
Groupie
Avatar

Joined: 10 Apr 2009
Online Status: Offline
Posts: 58
Quote Memoli28 Replybullet Posted: 19 Jun 2009 at 12:27pm

Dear DBlank,

the problem is also the following:
the field is not numeric because of the comma: (after the 6 and 1)
906,151,655.55
 
regards
memoli
 
IP IP Logged
Memoli28
Groupie
Groupie
Avatar

Joined: 10 Apr 2009
Online Status: Offline
Posts: 58
Quote Memoli28 Replybullet Posted: 19 Jun 2009 at 12:42pm
Dblank,
 
it is a senddatetime value,but not for sure since i cant check.
 
also dont know why the comma's are between it.
 
regards,
memoli
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jun 2009 at 12:48pm

I would double check the datatype and then do an internet search on that dattype for whatever database you are using and see if it explains the 4 components (3 comma seperated and the .xx at the end). From that you may be able to use a conversion process to consistently get the correct date time values.

IP IP Logged
Memoli28
Groupie
Groupie
Avatar

Joined: 10 Apr 2009
Online Status: Offline
Posts: 58
Quote Memoli28 Replybullet Posted: 22 Jun 2009 at 10:30am
hi All,
 
after winning some information from our administrator the  following formula is created:
just only for the date:

date(totext(field)[2 to 3]&'/'&totext(field)[5 to 6]&'/'&'200'&totext(field})[1])
 
in 2010 i have to change the '200' in '20'
 
regards,
Memoli

 
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum