Jump to content
Sign in to follow this  
pjdodd

Time to Words

Recommended Posts

Short story: I have a field that adds up the time field on a layout. It displays the results in hours and minutes, which looks ridiculous as the hours runs in to the 10,000s.

I need a function that turns these hours and minutes into years, months, days, hours and minutes. For example, 12,009:34 becomes say 0 Years 8 Months, 12 Days, 14 Hours and 34 Minutes.

(I understand the function will give a text result which is ok, and I am NOT looking for a compare time function - I've found too many of these). I'm guessing the function will be a mess of Case clauses but it's too complex for me to figure out.

Heeeellllllp!

(PS Please don't reply telling me the example is wrong, I know, it's an example).

Share this post


Link to post
Share on other sites

You can't convert such a value to years and months as these have a different value depending on the year or months used.

Share this post


Link to post
Share on other sites

Here is a quick one - you need to double check it as it's late here and my maths is a bit slow!

use "s" as the parameter passed to it - must be numeric. The highest value we can convert to is a Week (as we know how many secs are in a week!)

---------

Let

(

[

w= Int (s/ 604800) ; r=Mod ( s; 604800) ;

d= Int (r/ 86400 ); r=Mod ( r;86400) ;

h= Int (r/3600); r=Mod (r;3600) ;

m=Int (r/60); s=Mod (r ; 60)

]

;

w & " Weeks " & d & " Days " & h & " Hours " & m & " Minutes " & s & " Seconds" )

---------------------

Share this post


Link to post
Share on other sites

Thanks. It don't work - I get the error "A number, text constant..." appear.

I see the general idea but my field data is in hours and minutes...no seconds. Also doesn't this display the equivalent values ie 1 week = 7 days = 168 hours. I want the following

170 hours to show as

1 week, 0 days, 2 hours, 0 minutes.

868 hours, 23 minutes to show as

5 weeks, 1 day, 4 hours, 23 minutes.

I take your point about months and years but I'm happy to assume that each month is 30 days and each year 365...no rants people about the inaccuracy of the calendar! Thanks for your help.

Edited by Guest

Share this post


Link to post
Share on other sites

If you see the general idea, what's stopping you from adapting it to your needs?

Notes:

1. A time field converted a number is always the number of seconds;

2. I would use Div ( n ; d ) instead of Int ( n / d ).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Who Viewed the Topic

    1 member has viewed this topic:
    Will Xu 
×

Important Information

By using this site, you agree to our Terms of Use.