How to format duration type variable?

arcull
Member Posts: 191
Hi there. Anyone maybe knows how to format duration. I have the case where duration is difference between two datetimes, and would like to have displayed just days and hours, without minutes and seconds. Thanks for any suggestion.
0
Comments
-
Hi Arcull,
You can use the round function.
To remove the milliseconds:Duration2 := ROUND(DateTime1 - DateTime2, 1000);
To remove the millisecond and seconds:Duration2 := ROUND(DateTime1 - DateTime2, 1000 * 60);
Reijer Molenaar
Object Manager0 -
I see that you asked for removing the minutes also:
Duration2 := ROUND(DateTime1 - DateTime2, 1000 * 60 * 60);
Reijer Molenaar
Object Manager0 -
thanks reijermolenaar, It seems there is no other option but treating duration as integer and calculating time units from it, thanks again.0
-
Just convert it to a Date Time and then just use Standard Navision formatting if its just for display then there is no need to round.David Singleton0
-
Hi David,
Can you please give an example how to do that.
I cannot find these options in the help texts.
What expression do you use if you want to display it e.g. like this:
"12 days 3 hours 14 minutes"?Reijer Molenaar
Object Manager0 -
reijermolenaar wrote:Hi David,
Can you please give an example how to do that.
I cannot find these options in the help texts.
What expression do you use if you want to display it e.g. like this:
"12 days 3 hours 14 minutes"?
Try F1 on the FORMAT function.David Singleton0 -
I already did that and the options for day/days and hour/hours are not available.
So if you want to display your duration in full text you cannot convert it to Date Time? :-k
Or am I something missing here?Reijer Molenaar
Object Manager0 -
Well since you have given virtually no information about what you are trying to do I can only guess, but something like
'<Days,2> days <Hours,24> hours <minutes,2> minutes'
I guess.David Singleton0 -
I am starting to wonder if maybe F1 does not work in many country versions of Navision. ](*,)David Singleton0
-
F1 is working fine in the Netherlands!
As I said, there is no option for the days and minutes part in the format parameters.
You pass them as fixed text.
So how you handle plural like day/days?
And what about translation? NLD: Dagen ENU: Days
If you do a FORMAT(duration) NAV handles all these things.
If you convert to a datetime variable you lose all this functionality.Reijer Molenaar
Object Manager0
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