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, ...
Suggested Answer

Find the date format from a given date

(0) ShareShare
ReportReport
Posted on by 50

Hi,

How to find the date format from the given date? I have a requirement to print the date format in Purchase order confirmation next to the date. The below code is what I am using, but there is a mismatch between the date and date format value. 

PurchTable purchTable = PurchTable::find(purchheader.PurchId);
System.Globalization.CultureInfo cinfo;
if(purchTable)
{
cinfo = new System.Globalization.CultureInfo(purchTable.LanguageId);
purchheader.DateFormat_DIS = '[' + cinfo.DateTimeFormat.ShortDatePattern + ']';
}

I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    What are you trying to achieve from the business point of view? Why do you want store the default date pattern for the given culture in database?

    By the way, you said you want "to find the date format from the given date", but your code doesn't take any information from the given data. You merely store the server-wide configuration applicable to all dates.

    Also, note that the culture determined from PurchTable.LanguageId may be different than the culture used in GUI. GUI normally uses the culture configured for the current user. Users with different setup can see the same date rendered in different formats.

  • ShruthiKrishnaswamy95 Profile Picture
    50 on at

    Hi Martin,

    I need to show the date format next to the date in Purchase order confirmation report. Yes, I agree that the date input is not given, but I read that the date format gets picked up based on the regional language setup. That is the reason why I have provided the language input to find from the culture.

    Followed the link:

    community.dynamics.com/.../297032

    Thanks for the information, I wasnt aware about the difference in the GUI.

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    If it's about the confirmation report, determining culture from PurchTable.LanguageId looks good to me.

    Which of the value is wrong? Are you saying that the format definition is wrong or that the date is formatted in a wrong way?

  • ShruthiKrishnaswamy95 Profile Picture
    50 on at

    So , the vendor language is "EN-US". If I set the format from the system as "DD-MMM-YY", in the report, I am able to see the format , but the date is in the original format. Shouldn't the date be formatted in the same way as well?

    Screenshot-_2800_14_2900_.png

    I am getting confused with the behaviour of the system -  Should I get the format based on the date or the language?

  • ShruthiKrishnaswamy95 Profile Picture
    50 on at

    Any suggestions?

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    I'm sorry, I don't have time to play with it. Consider logging it as a bug and complaining that SSRS reports don't respect the data format. You'll see what Microsoft says.

  • ShruthiKrishnaswamy95 Profile Picture
    50 on at

    Hi Martin,

    As suggested, I had raised MS support ticket. Over call, I was able to show the support executive that after changing the user preferences date format, the Purchase order confirmation report does not reflect the changes. This was seen even in his standard environment. So he has suggested to raise it further with the PG team.

    Do you have any suggestions or ideas, going back to the original question? If given a date, is there any standard code available to find the date format of the same?

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at

    Date data doesn't have any format associated with it. So you can't determine a format from a date.

    Well, of course this depends on what you meed by "given date" but if we are talking about Date fields in D365, my statement applies.

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
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans