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

Announcements

No record found.

News and Announcements icon
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,430

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
    239,142 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,430 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
    239,142 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 649

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 447 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 242 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans