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

Notifications

Announcements

No record found.

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
    237,970 Most Valuable Professional on at

    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

    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
    237,970 Most Valuable Professional on at

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans