Convert Integer to hours

ricky76
Member Posts: 204
Hi, I wondered if anyone could help me. I want to convert an integer value to hours and minutes but am not sure how to do it. For example i have the integer value 200 and i want to show this as 3:20:00. Any help would be most appreciated.
0
Comments
-
standard you've got the evaluate function.
But if you've got some transformation of your own in mind you should write a function.
200 trough evaluate with a time variable shows 20:00:000 -
Hi,
My suggestion is simple. Use variable of type Duration (represent the difference between two datetimes, in milliseconds.) to calculate time.
Example:// 03:20 = (3 * 60 minutes) + 20 minutes = 200 minutes // 200 minutes = 200 * 60 seconds = 12 000 seconds // 12 000 seconds = 12 000 * 1000 milliseconds = 12 000 000 milliseconds varInteger := (3 * 60 + 20) * 60 * 1000; // desired time specified in milliseconds. varDuration := var varInteger; varTime := 0000T + varDuration; MESSAGE(FORMAT(varTime)); // result is 03:20:00
So simply add some duration period in milliseconds to zero time and calculating a new time.
Hope it help.0 -
Thank you for your help. I did manage to get this sorted using something similar to what Spawn wrote. Many thanks.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions