Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: How to convert dd hh:mm:ss to seconds Post Reply Post New Topic
Author Message
jennifer_falcon
Newbie
Newbie
Avatar

Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
Quote jennifer_falcon Replybullet Topic: How to convert dd hh:mm:ss to seconds
     Posted: 24 Dec 2010 at 9:56am
Good Day,

I have a field in my database that keeps a running total of a clock. The field is called Total.Alias.

This field can have a variety of information in it.
It could be:
00:00:00
01 00:01:12
354 11:02:25
1005 09:05:36

So, in theory, the running total could be in the hundreds of days.

I need to be able to convert that time to seconds.

Can someone tell me how to do this?

Thanks!
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 25 Dec 2010 at 10:10am
I don't know if there is a direct function, but you can probably manually calculate it.

Assuming the field is a DateTime field, you can extract the information using

day
hour
minute
second

functions and convert them to seconds before adding them up.
So like

day({field}) * 86400 + hour({field}) * 3600 + minute({field}) * 60 + second({field})

On the other hand, if it's a string, then you can split it so that the last two chars are the seconds, ignore the colon, then take the next two as minutes, ignore the colon, then take the next two as the hour. Everything else would be the day.


Edited by Keikoku - 25 Dec 2010 at 12:12pm
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