Hello everyone,
I’m facing a issue and i need help
I have var called timer (time datatype)
It should calculate difference between two times and save the result
I want to add the this timer variable with the difference between start time and the end time
Timer + (endtime-starttime)
Timer : 23:30:00 saved in db
Start time : 1:00:00
End time: 12:00:00
It’s gonna be 34 hours and 30 min
I need like
1 day 10 hours 30 min
I have tried this function:
AddSeconds(timer(starttime-endtime)
Disadvantages: more than 24 hours will count as zero and start again from 00:00:00
I need function that count timee in
(dd:hh:mm:ss)
Hi,
Please refer below post for your Query,
https://www.outsystems.com/forums/discussion/56669/add-timehhmmss/
Thanks
CV
Thank you but the solutions not match with my issue i need it in (dd:hh:mm:ss)
Based on time data type so if the timer more than 24 hours consider as a day
Hi @Jumanah Aldulaim ,
you say that your variable is a time, that by definition doesn't know about days. Use a DateTime instead.
For a how to, see @Siya reply.
Thank you for your repay but i need to calculate based on time not in datetime , i need to sum time if more that 24 hours consider it as a day and continue count … like 2 day 12 hours 30 minutes.. and so on
There is simply no place for days in a time variable.
If you object to the datetime format, you could just store it as integer (i.e. number of seconds) that's for storage / counting.
As for display, write a small client function converting seconds into the string representation you need.
But seriously, DateTime will work just fine.
Believe this for just rendering on the screen. Attached an implementation of the same.
Thank you i will try it
check this
Still not match with my issue
I need to get the days based on the the adding saved timer with the difference between two (time attributes)
AddSeconds(timer(starttime-endtime) >24 hours?
Consider it as one day then continue check again
Ex: 1 day 23 hours 50 minutes 20 second
AddSeconds(timer(starttime-endtime)> 24 hours
Consider it as two days then continue check again;,,
Because if i use this function AddSeconds(timer(starttime-endtime) it doesn’t calculate days
How?
Hi Jumanah,
You are mixing up data storage and representation. The best thing you can do is store the difference as a number of seconds (in an Integer), and convert that to a dd:hh:mm:ss representation using an action that calculates the various components, and returns those, so you display it on screen (or an action that builds the entire dd:hh:mm:ss Text).
i did and it works thank you ,but is it good for data storage ? because the number in seconds is huge number imagine we had 40 hours ..
If you use an Integer, you can represent 2,147,483,647 seconds, which is about 68 years. If you want to go further, use a Long Integer. This will give you enough seconds to represent more years than the age of the universe :).
(40 hours is just 144,000 seconds, which is a relatively small number)
Thank you
You're welcome. Don't forget the answers that helped you as Solution, thanks!
these are the function i used to get days,hours,mintues and seconds based on number of seconds
At a first glance that seems to work, though it's easily testable :).