Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

How to display today date from online server

Posted on by 751

Hello,

can anybody help me in writing a codeunit to display current date from online server?

Regards,

David

  • David Tailor Profile Picture
    David Tailor 751 on at
    RE: How to display today date from online server

    hi ZHU,

    i checked your code, however if we are talking on prem environment, possible to display the current date from an online server?

    Regards,

    David

  • ManishS Profile Picture
    ManishS 6,578 on at
    RE: How to display today date from online server

    What is you purpose of getting server date for ?

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    RE: How to display today date from online server

    Hi, As far as I know, the BC SaaS version has no concept of server dates. If you need UTC, I hope the following information can give you some hints.

    How to quickly get Coordinated Universal Time (UTC Time)

    https://yzhums.com/17060/

    pastedimage1678154458200v1.png

    Thanks.

    ZHU

  • David Tailor Profile Picture
    David Tailor 751 on at
    RE: How to display today date from online server

    Hi Daniele,

    i replaced the function SYSTEMTIME2DATE with DT2DATE it works.

    however it is displaying the system date.

    means: if i changed the system date to for 5 Apr 2022, it is showing the same not the current date.

    Regards,

    David

  • David Tailor Profile Picture
    David Tailor 751 on at
    RE: How to display today date from online server

    Hi Daniele,

    i receive an error for the function SYSTEMTIME2DATE :

    "the name does not exist"

    Regards,

    David

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: How to display today date from online server

    hi

    try this:

    codeunit 50100 DisplayCurrentDate

    {

       procedure GetDate()

       var

           CurrentDate: Date;

       begin

           CurrentDate := SYSTEMTIME2DATE(CURRENTDATETIME);

           MESSAGE('The current date is %1.', CurrentDate);

       end;

    }

    This codeunit contains a procedure called "GetDate" that retrieves the current date and time from the online server using the "CURRENTDATETIME" function. The "SYSTEMTIME2DATE" function is then used to convert the date and time to a date value.

    check my answer if it helped you, thanks

    DAniele

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How to display today date from online server

    Please refer the below link, surely it will help you.

    learn.microsoft.com/.../devenv-page-ext-object

  • David Tailor Profile Picture
    David Tailor 751 on at
    RE: How to display today date from online server

    there is no code. if you can help me with a code like Hello world standard of VS code.

    a page extension or a codeunit that will be called on any page extension.

    we can extend Customer List page

    Regards,

    David

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How to display today date from online server

    can you please share your code? where you want to display?

  • David Tailor Profile Picture
    David Tailor 751 on at
    RE: How to display today date from online server

    On cloud.

    but it can works on both right?

    Regards,

    David

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans