How to make a HMS2TIME?

pdj
Member Posts: 643
I need a function like the DMY2DATE, just for TIME variables.
There is no problem in just making a simple function like this:
It seems to be possible to do like this:
Thanks in advance
There is no problem in just making a simple function like this:
Function:HMS2TIME(Hour : Code[2];Minute : Code[2];Second : Code[2]) Time : Time EVALUATE(Time,Hour+':'+Minute+':'+Second);But how do I insure that it works for all imaginable reginal setting?
It seems to be possible to do like this:
Time := 123012T;But not like this:
EVALUATE(Time,'123012T');I can see that 4.00 introduce a new parameter for EVALUATE to solve the problem, but what should I do for 3.60?
Thanks in advance
Regards
Peter
Peter
0
Comments
-
I believe this will work for all regional settings, if you take care to provide exactly 6 digits, and presuming the hour is supplied in (or converted to) 24hour form:
EVALUATE(Time,'123012');
0 -
You want to get sure for formating the time in right format.
so you should define this format
like
Time:= format(<hours24,2>,<minutes,2>,<seconds,2>);
or in what format you really want to do this.
maybe need to use <filter character> to obtain perfectly0 -
If you want to have a possibility to convert three integer variables ti time, use arithmetic functions like
TimeVar := 000000T + ((Hours * 60 + Minutes) * 60 + Seconds) * 1000 + miliSeconds;
To be sure that get a correct hour, minute... variable values check them.0 -
fb> It seems to work. Thanks.
eksekj> How can I use FORMAT from Text to Time? I thougt it was only the opposite..
i4tost> Seems to work as well. Thanks.
I actually have milliseconds as well, so I will use i4tost's method, but thanks to all of you :-)Regards
Peter0
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