Business Central 2024 wave 2 (BC25): New Date/Time/DateTime methods

Dynamics 365 Business Central

Hi, Readers.
The public preview for Dynamics 365 Business Central 2024 release wave 2 (BC25) is available. Learn more: Link.

I will continue to test and share some new features that I hope will be helpful.

In this post, I would like to talk about new Date/Time/DateTime methods in Business Central 2024 release wave 2 (BC25). This is not yet documented in the Business Central 2024 release wave 2 (BC25) release plan. But it is mentioned in AL Language extension changelog Version 14.0

This idea came from feedback from this year’s BC Tech Days.
Source:

In fact, the table above has explained it very clearly, but let me do a simple test.

Date Data Type:

Test code:

pageextension 50100 MyExtension extends "Sales Order"
{
    layout
    {
        modify("Posting Date")
        {
            trigger OnAfterValidate()
            begin
                Message(Msg, Rec."Posting Date".Year, Rec."Posting Date".Month, Rec."Posting Date".Day, Rec."Posting Date".WeekNo, Rec."Posting Date".DayOfWeek);
            end;
        }
    }
    var
        Msg: Label 'Year: %1\Month: %2\Day: %3\Day Of Week: %4\Week No.: %5';
}

Time Data Type:

Test code:

pageextension 50100 MyExtension extends "Sales Order"
{
    layout
    {
        modify("Posting Date")
        {
            trigger OnAfterValidate()
            begin
                Message(Msg, Time.Hour, Time.Minute, Time.Second, Time.Millisecond);
            end;
        }
    }

    var
        Msg: Label 'Hour: %1\Minute: %2\Second: %3\Millisecond: %4';
}

DateTime Data Type:

Test code:

pageextension 50100 MyExtension extends "Sales Order"
{
    layout
    {
        modify("Posting Date")
        {
            trigger OnAfterValidate()
            begin
                Message(Msg, Rec.SystemCreatedAt.Date, Rec.SystemCreatedAt.Time);
            end;
        }
    }
    var
        Msg: Label 'System Created At Date: %1\System Created At Time: %2';
}

PS: Date part and Time part of DateTime Data Type also support new methods

Great improvement. Give it a try!!!😁

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL