Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Changin Hours:minutes into Decimal Post Reply Post New Topic
Author Message
JessH
Newbie
Newbie


Joined: 23 Jan 2017
Location: United Kingdom
Online Status: Offline
Posts: 1
Quote JessH Replybullet Topic: Changin Hours:minutes into Decimal
    Posted: 25 Jan 2017 at 4:07am
I have a field (a string apparently) which holds data as 1:30 ie 1 hour 30 mins.

I want to return it as 1.5 (numeric) - however when I try to use 'ToNumber' on the field I get an error 'The string is not numeric'.

This happens even if try to grab the hour and minutes parts separately. Help!
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 25 Jan 2017 at 4:26am
That is because Crystal Reports is smart enough to know what to do when there is a colon in a string.  The following formula might work for you.
ltonumber(eft({string},instr({string},":")-1))+(tonumber(mid({string},instr({string},":")+1))/60)
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.047 seconds.