web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Getting wrong date and time

(0) ShareShare
ReportReport
Posted on by 2,382

Hello Experts,

I have a display method under table CustInvoiceJour.

In method I used code like below:

utcDateTime Timestamp;
str Timestamp1;
Timestamp=this.createdDateTime;
Timestamp1=datetime2str(Timestamp);

and finally added Timestamp1 to QR code.When I check entry in under Inquiry form like below Date and Time is correct.

8171.T1.jpg

But in QR code information Date is correct but Time is not correct.

QR_5F00_Code_5F00_Info.jpg

Thanks,

Faiz

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: Getting wrong date and time

    You forgot to apply user's timezone.

    Datetime values are stored in UTC in database. They're automatically convert to user's timezone in forms, but it's your responsibility in your code.

    Use DateTimeUtil::applyTimeZoneOffset().

  • faiz7049 Profile Picture
    2,382 on at
    RE: Getting wrong date and time

    Hi Martin,

    Sorry I did not know before. How to apply like

    utcDateTime Timestamp, Timestamp2;
    str Timestamp1;
    Timestamp=this.createdDateTime;
    Timestamp2= DateTimeUtil::applyTimeZoneOffset(Timestamp,UTC 03:00);
    Timestamp1=datetime2str(Timestamp2);

    Please guide me if you do not mind.

    Thanks,

    Faiz

  • Verified answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: Getting wrong date and time

    I don't think you really want to hard-code the timezone in code. Most likely, you want the timezone configured for the current user:

    DateTimeUtil::applyTimeZoneOffset(timestamp, DateTimeUtil::getUserPreferredTimeZone()));

    Alternatively you might want the timezone of the current company.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,122

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 918 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 646 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans