Duration (TIME) to close of day (Midnight)
Dean_Axon
Member Posts: 193
I'm trying to find the DURATION based on a time I enter (say 23:30:00) to Midnight (24:00:00 or 00:00:00 as navision Help says).
My Problem is that when I do this:
Duration := 000000T-MyTime;
(Duration := 000000T-23:30:00)
I get -23 hours and 30 minutes
How do I get the difference of 30 minutes with C/AL Code ?!?!!?!?!
Any help would be appreciated, in fact ALL help would be appreciated.
My Problem is that when I do this:
Duration := 000000T-MyTime;
(Duration := 000000T-23:30:00)
I get -23 hours and 30 minutes
How do I get the difference of 30 minutes with C/AL Code ?!?!!?!?!
Any help would be appreciated, in fact ALL help would be appreciated.
Remember: Keep it simple
0
Comments
-
You should use DateTime data types. Try something like the following:
MidNight := CREATEDATETIME(020907D,000000T); myDuration := MidNight - CURRENTDATETIME;
In the above example, MidNight is just a variable of DateTime. You can of course substitute the 020907D literal with a CALCDATE call or whatever value suits your needs.Thad Ryker
I traded my sanity for a railgun
0 -
Dur := CREATEDATETIME(020100D,0T)-CREATEDATETIME(010100D,MyTime);
0 -
well sure if you want to go and optimize it to one line ;p *grin*
I still like using meaningfull variable names for constant values
Or maybe even define a function TIMETILLMIDNIGHT and drop the code there:)
I guess we all have our individual preferences heheheheThad Ryker
I traded my sanity for a railgun
0 -
I ended up doing this...
HourstoMidnight[1]:=235959t-inTime[1]; HourstoMidnight[1]+=1000;
Not as clean, but functional.
Will try some of these suggestions thoughRemember: Keep it simple0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
