If I have a numeric field that contains the integer # 41, how do I get that into a Duration field so that it displays "1 days 17 hours, etc." ?
It might also be 41.5 for 41 hrs, 30 mins
[Solved] how do i get a number into a Duration field?
[Solved] how do i get a number into a Duration field?
Last edited by Jaymer on Tue Sep 10, 2019 12:32 am, edited 2 times in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: how do i get a number into a Duration field?
... or another example:
if you were record times, its not quick to have a user enter 8:30 because
1) You cannot use 10-key pad - you have to enter the :
2) User wants to enter 8.5 for 8 1/2 hours (not enter 8 hrs 30 mins)
So for quick entry, you could allow time entry into a numeric field, THEN convert it into a Duration.
But I can't seem to just a simple : timeentry.DurationField = timeentry.NumericField
The duration always shows 0
if you were record times, its not quick to have a user enter 8:30 because
1) You cannot use 10-key pad - you have to enter the :
2) User wants to enter 8.5 for 8 1/2 hours (not enter 8 hrs 30 mins)
So for quick entry, you could allow time entry into a numeric field, THEN convert it into a Duration.
But I can't seem to just a simple : timeentry.DurationField = timeentry.NumericField
The duration always shows 0
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
Re: how do i get a number into a Duration field?
ok, here's a not so elegant solution:
I need a dummy timestamp field to store the result of adding Hrs&Mins to midnight.
Now, I subtract that from midnight to get a duration.
Written as 1 line now:
Code: Select all
TicketTime.Timestamp_test = TIME_ADD( AS_TIMESTAMP('01-01-2000 00:00' , 'MM-dd-yy HH:mm'), TicketTime.resource_sch_time_hours )
TicketTime.Duration_test = TIME_ADD( AS_TIMESTAMP('01-01-2000 00:00' , 'MM-dd-yy HH:mm'), TicketTime.resource_sch_time_hours )
TicketTime.Duration_test = TicketTime.Timestamp_test - AS_TIMESTAMP('01-01-2000 00:00' , 'MM-dd-yy HH:mm')
Now, I subtract that from midnight to get a duration.
Written as 1 line now:
Code: Select all
TicketTime.Duration=TIME_ADD(AS_TIMESTAMP('01-01-2000 00:00','MM-dd-yy HH:mm'),TicketTime.resource_sch_time_hours)-AS_TIMESTAMP('01-01-2000 00:00','MM-dd-yy HH:mm')
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
-
- Posts: 2413
- Joined: Mon Jul 02, 2012 12:24 am
- Location: Ulaanbaatar, Mongolia
Re: how do i get a number into a Duration field?
I just use HHh MMm for the format
Displays as...
Displays as...
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Re: how do i get a number into a Duration field?
MARK -->
You can't just assign a number (41 for ex.) to a Duration field.Jaymer wrote:If I have a numeric field that contains the integer # 41, how do I get that into a Duration field so that it displays "1 days 17 hours, etc." ?
It might also be 41.5 for 41 hrs, 30 mins
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL
-
- Posts: 2413
- Joined: Mon Jul 02, 2012 12:24 am
- Location: Ulaanbaatar, Mongolia
Re: how do i get a number into a Duration field?
Ah... misread...
Just assign the value 147,600,000 to the Duration attribute and set its diaplay format to DDd HHh MMm
Just assign the value 147,600,000 to the Duration attribute and set its diaplay format to DDd HHh MMm
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Re: how do i get a number into a Duration field?
Actually, you CAN assign a number to a Duration field if you know the formula.
Duration is a BIGINT field that store MILLISECONDS.
So if you want to set a Duration of 1 hour, you just set that field to 3,600,000
... and off you go.
If you want to store a duration and you have your values in 2 diff fields (myHrs, myMin) then its:
BO.Duration = BO.myHrs * 3600000 + BO.myMin * 60000
The Duration for 4.25hrs is 15300000
--> JaymerTip
Duration is a BIGINT field that store MILLISECONDS.
So if you want to set a Duration of 1 hour, you just set that field to 3,600,000
... and off you go.
If you want to store a duration and you have your values in 2 diff fields (myHrs, myMin) then its:
BO.Duration = BO.myHrs * 3600000 + BO.myMin * 60000
The Duration for 4.25hrs is 15300000
--> JaymerTip
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.
Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Aware Programming & Consulting - Tampa FL