Notifications
Announcements
No record found.
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 + ']'; }
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.
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.
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?
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?
I am getting confused with the behaviour of the system - Should I get the format based on the date or the language?
Any suggestions?
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.
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?
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 611 Most Valuable Professional
André Arnaud de Cal... 529 Super User 2025 Season 2
Sohaib Cheema 285 User Group Leader