Converting Decimal to Date + Time

Franco_FestiFranco_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

Comments

  • kinekine Member Posts: 12,562
    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.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Franco_FestiFranco_Festi Member Posts: 19
    thank you very much kine.

    :)

    PS: any suggestions about how to have the right date using Excel ?
  • kinekine Member Posts: 12,562
    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.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.