DateTime difference

SeaMaster
Member Posts: 5
Hi,
I have a problem in Navision 3.10.
Say we have 4 variables:
Date1 - date someone enter the room
Time1 - time someone enter the room
Date2 - date someone exit the room
Time2 - time someone exit the room
I want to calculate the difference between Date1, Time1 and Date2, Time2.
The result could be something like this:
1 day 2 hours 12 minutes 12 sec.
I can't use the DateTime variable and CREATEDATETIME function
because it is not supported in Navision 3.10.
How do I do this.
Thanks in advance.
I have a problem in Navision 3.10.
Say we have 4 variables:
Date1 - date someone enter the room
Time1 - time someone enter the room
Date2 - date someone exit the room
Time2 - time someone exit the room
I want to calculate the difference between Date1, Time1 and Date2, Time2.
The result could be something like this:
1 day 2 hours 12 minutes 12 sec.
I can't use the DateTime variable and CREATEDATETIME function
because it is not supported in Navision 3.10.
How do I do this.
Thanks in advance.
0
Comments
-
why dont u use this little code:
duration := createdatetime(Date2,Time2) - createdatetime(Date1,Time1);
0 -
oh sorry i saw it too late, heres a code without the dattime datatype and function:
duration := (date2 - date1) * 86400000; duration := duration + (time2 - time1);
Greez Warfox0 -
What kind of datatype should Duration variable be. I get a strange number.0
-
integer (if you don't have duration)®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
and the result is in miliseconds... so you have some excercise to do your formating...®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
No the result will be in days because i multiply by 86400000.
86400000 = 24(hours) * 60(minutes) * 60(seconds) * 1000(miliseconds)0 -
well, to be exact:
date2 - date1 returns integer representing days. after multiplying with 86400000, result is integer representing miliseconds.
time2 -time1 returns integer representing milisecond.
so at the end we have difference in miliseconds.®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
Thats, right but only with an integer, with the duration data type the return of Time2 -Time1 will be in hours, i don´t know why, but it is so :shock: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