Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Time Function Rounding to Midnight Post Reply Post New Topic
Author Message
BlakeJ
Newbie
Newbie
Avatar

Joined: 27 Aug 2007
Location: United States
Online Status: Offline
Posts: 11
Quote BlakeJ Replybullet Topic: Time Function Rounding to Midnight
     Posted: 18 Sep 2009 at 11:23am
I'm having a couple of problems with Crystal XI converting a varchar datetime field to the correct format.  The datetime field comes in as a string: 20090730121256.
 
I tried using the DateTime function in the following formula but I get an "invalid format" error:
 
DateTime(Left({EFFECTIVE_DATE},4) + ',' +
Mid({EFFECTIVE_DATE},5,2) + ',' +
Mid({EFFECTIVE_DATE},7,2) + ',' +
(Mid({EFFECTIVE_DATE},9,2) + ',' +
Mid({EFFECTIVE_DATE},11,2) + ',' +
Right({EFFECTIVE_DATE},2))
)
 
This format works only if I break the above out into a Date function and then a Time function, and then combine those into a DateTime function.  But, either way, it keeps rounding the time, which should show 12:12:56, to 12:00:00.  How do I stop it from rounding the time?
Blake
IP IP Logged
Jyothi Yepuri
Senior Member
Senior Member


Joined: 11 May 2009
Location: Australia
Online Status: Offline
Posts: 127
Quote Jyothi Yepuri Replybullet Posted: 20 Sep 2009 at 10:11pm
Try this
Stringvar x:="20090730121256";
NUMBERVAR HH:= TONUMBER(Mid(x,9,2));
NUMBERVAR MM:=TONUMBER(Mid(x,11,2));
NUMBERVAR SS:= TONUMBER(Right(x,2));

DATEVALUE(Left(x,4) + ',' +Mid(x,5,2) + ',' + Mid(x,7,2))+ TIMEVALUE(HH,MM,SS)

Jyothi
IP IP Logged
BlakeJ
Newbie
Newbie
Avatar

Joined: 27 Aug 2007
Location: United States
Online Status: Offline
Posts: 11
Quote BlakeJ Replybullet Posted: 21 Sep 2009 at 4:45am
That worked.  Thanks!
Blake
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