Converting Decimal to Date + Time
Franco_Festi
Member Posts: 19
Hi guys,
I need to know how Navision calculates date and time from a decimal field. The problem is that i don't need to do it on C/AL, but i just need to know the criteria.
This is my field :
"Starting Date-Time" (Data Type = Decimal,AutoFormatType = 10, AutoFormatExpr='DATETIME').
Checkin it out with Tools -> Zoom it says : 63.333.331,070033
Checkin it out with RUN it says : 14/12/06 15.57.50
Taking a look at codeunit 416 (Datetime Mgt.)
Datetime2Date(Datetime : Decimal) : Date
IF Datetime = 0 THEN
EXIT(0D);
EXIT(01010000D + ROUND(Datetime/86.400,1,'<'));
and then :
Datetime2Time(Datetime : Decimal) : Time
IF Datetime = 0 THEN
EXIT(0T);
EXIT(000000T + (Datetime MOD 86.400) * 1000000);
But what's the value inside 01010000D ? I mean, copying my field to Excel, which kind of operation do i need to do ?
Hope i was clear enough... thank you in advance guys.
Franco
I need to know how Navision calculates date and time from a decimal field. The problem is that i don't need to do it on C/AL, but i just need to know the criteria.
This is my field :
"Starting Date-Time" (Data Type = Decimal,AutoFormatType = 10, AutoFormatExpr='DATETIME').
Checkin it out with Tools -> Zoom it says : 63.333.331,070033
Checkin it out with RUN it says : 14/12/06 15.57.50
Taking a look at codeunit 416 (Datetime Mgt.)
Datetime2Date(Datetime : Decimal) : Date
IF Datetime = 0 THEN
EXIT(0D);
EXIT(01010000D + ROUND(Datetime/86.400,1,'<'));
and then :
Datetime2Time(Datetime : Decimal) : Time
IF Datetime = 0 THEN
EXIT(0T);
EXIT(000000T + (Datetime MOD 86.400) * 1000000);
But what's the value inside 01010000D ? I mean, copying my field to Excel, which kind of operation do i need to do ?
Hope i was clear enough... thank you in advance guys.
Franco
0
Comments
-
01010000D is date 1.1.0000 (Year 0). It is the base date from which the date and time is calculated.
Datetime/86.400 is number of days since 1.1.0000. To get date you need to add the number of days to some base date (01010000D) to get new date.0 -
thank you very much kine.

PS: any suggestions about how to have the right date using Excel ?0 -
No, but you can find out the decimal value for date e.g. 1.1.1900, subtract this value from the calculated one and the rest add to date 1.1.1900 as number of days from this date.0
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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 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
