Notifications
Announcements
No record found.
Hello everyone,
I'm facing an issue with Hijri dates in D365 F&O.
The problem first occurred when I created a "Display Method" for the first time using this code:
public static str ConvertToHijri(TransDate _TransDate) { TransDate dateTime = _TransDate; CalendarConverter calendarConverter = new CalendarConverter(PreferredCalendar::Hijri); int hijriDay; int hijriMonth; str hijriYear, finalHijriDate; str hijriDayStr, hijriMonthStr, hijriYearStr; hijriDay = calendarConverter.dayofmth(dateTime); hijriMonth = calendarConverter.mthofyr(dateTime); hijriYear = calendarConverter.yearStr(dateTime); hijriDayStr = int2str(hijriDay); hijriMonthStr = int2str(hijriMonth); hijriYearStr = hijriYear; finalHijriDate = hijriYearStr + '/' + hijriMonthStr + '/' + hijriDayStr; return finalHijriDate; }
As you can see, this code had an issue where it advanced the date by one day. For example, the date 2024/11/17 returns as 1446/5/16, which is somewhat incorrect, as the correct corresponding date is 1446/5/15.
I resolved the issue by changing the code from "PreferredCalendar::Hijri" to "PreferredCalendar::UmAlQura" , and it worked; the date now correctly returns as 1446/5/15.
"PreferredCalendar::Hijri"
"PreferredCalendar::UmAlQura"
Now, I am facing the same issue in SSRS reports. I followed the steps in this question: How to convert date from gregorian to hijri in SSRS report?
I changed the Calendar property to Hijri, and when I ran the report, I encountered the same issue of shifting the date forward by one day, such as the 2024/11/17 Gregorian date.
I tried solutions like adding a new column to the report table LedgerTransStatementTmp, but I found that the class LedgerTransStatementDP is somewhat complex, and I couldn’t figure out where to add the value for the field I added to the table.
LedgerTransStatementTmp
LedgerTransStatementDP
I hope you can help me with this problem, and thank you for your time.
public static str convertToHijri(TransDate _transDate) { CalendarConverter calendarConverter = new CalendarConverter(PreferredCalendar::Hijri); return strFmt('%1/%2/%3', calendarConverter.dayOfMth(_transDate), calendarConverter.mthOfYr(_transDate), calendarConverter.yearStr(_transDate)); }
public static str convertToHijri(TransDate _transDate) { CalendarConverter calendarConverter = new CalendarConverter(PreferredCalendar::UmAlQura); return strFmt('%1/%2/%3', calendarConverter.dayOfMth(_transDate), calendarConverter.mthOfYr(_transDate), calendarConverter.yearStr(_transDate)); }
System.DateTime dateTime = new System.DateTime(2024, 11, 17); CultureInfo culture1 = new CultureInfo('ar-SA', false); // Uses UmAlQuraCalendar CultureInfo culture2 = new CultureInfo('ar-SA', false); // Use HijriCalendar HijriCalendar hijriCalendar = new HijriCalendar(); hijriCalendar.HijriAdjustment = 2; DateTimeFormatInfo dateTimeFormat = culture2.DateTimeFormat; dateTimeFormat.Calendar = hijriCalendar; str s1 = dateTime.ToString('dd', culture1.DateTimeFormat); str s2 = dateTime.ToString('dd', culture2.DateTimeFormat);
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 664 Most Valuable Professional
André Arnaud de Cal... 522 Super User 2025 Season 2
Sohaib Cheema 303 User Group Leader