Jump to content
  • 0
Sign in to follow this  
ezIQchad

Calculated Dates Precision

Question

Hello all;

I am trying to log the time users are logged in, and I am unable to get any precision.

 

I would like hours to be displayed with two decimal places of accurate precision, but Datediff rounds to the nearest unit of time.  This (IMO) should be fairly easy to overcome by using a smaller unit of time, and dividing that large number by 60 or 3600 (for minute or second), but no luck.

 

Using the following sessions let's look at what I want, what I've tried, and what I'm getting.

SessionID = 1 | LoginDT 8-17-2014 09:00:00 | LogoutDT 8-17-2014 09:15:00

SessionID = 2 | LoginDT 8-17-2014 10:00:00 | LogoutDT 8-17-2014 10:40:00

SessionID = 3 | LoginDT 8-17-2014 11:00:00 | LogoutDT 8-17-2014 13:30:00

 

Desired Result:

SessionID = 1 | Logged Hours 0.25

SessionID = 2 | Logged Hours 0.67

SessionID = 3 | Logged Hours 2.50

 

Datediff(hour,[@field:LoginDT],[@field:LogoutDT])

SessionID = 1 | Logged Hours 0.00

SessionID = 2 | Logged Hours 0.00

SessionID = 3 | Logged Hours 2.00

 

Datediff(minute,[@field:LoginDT],[@field:LogoutDT])

SessionID = 1 | Logged Hours 15.00

SessionID = 2 | Logged Hours 40.00

SessionID = 3 | Logged Hours 150.00

 

Datediff(minute,[@field:LoginDT],[@field:LogoutDT])/60

SessionID = 1 | Logged Hours 0.00

SessionID = 2 | Logged Hours 0.00

SessionID = 3 | Logged Hours 2.00

 

(Datediff(minute,[@field:LoginDT],[@field:LogoutDT]))/60

SessionID = 1 | Logged Hours 0.00

SessionID = 2 | Logged Hours 0.00

SessionID = 3 | Logged Hours 2.00

 

Round(Datediff(minute,[@field:LoginDT],[@field:LogoutDT])/60,2)

SessionID = 1 | Logged Hours 0.00

SessionID = 2 | Logged Hours 0.00

SessionID = 3 | Logged Hours 2.00

 

Round((Datediff(minute,[@field:LoginDT],[@field:LogoutDT]))/60,2)

SessionID = 1 | Logged Hours 0.00

SessionID = 2 | Logged Hours 0.00

SessionID = 3 | Logged Hours 2.00

 

Any ideas?

Thanks!

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hello EIQ,

 

Please, try

Datediff(minute,[@field:LoginDT],[@field:LogoutDT])/60.00

 

As far as I know, Calculated Fields try to display result in the DataType that are used in calculations. For example, you divide by "60" - and the Result is Integer. If I understand correctly, if you divide by "60.00" - Result will be General, like 0.25.

By the Formatting button you can define how many digits after decimal will be displayed.

Share this post


Link to post
Share on other sites
  • 0

Hello,

Just wanted to inform you about the new feature in Caspio
Check this documentation in Caspio’s Help center: https://howto.caspio.com/release-notes/caspio-bridge-13-0/
This release includes a new feature of Calculated value in submission form option that allows you to use a calculated field in one of your field that is saved in your table. 
However, this feature only available in the ‘Submission DataPage’.
You can also check this documentation about calculated value: https://howto.caspio.com/datapages/datapage-components/calculated-values/ 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...