Blog

Microsoft Dynamics AX Blog

5

In a previous post, I descriped in deatils how to gte (and set) Hijri date in Microsoft Dynamics AX 2009. In that post I have shown how to get Hirji date in Dynamics AX by calling a SQL function from X++.

A calleague of mine has also came up with another great idea to handle the Hirji date using the CLR Interoperability. The standard Dynamics AX 2009 comes with a set of very important .NET libraries referenced to be used automatically in Dynamics AX 2009.

 

References in AOT

 What you could use out of those libraries: System.Globalization library of .NET framework. But of course, you have to use a string to show the value of that date since you cannot get a Hirji date (with its values like 1430 as a year) and assign it to an X++ date datatype.

Check out this code to have the Hirji date converted from X++ gregorian date:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 display STRExtendedDT ExpieryDate_H()
{
    System.Globalization.Calendar           Calendar = new System.Globalization.HijriCalendar();
    System.Globalization.DateTimeFormatInfo hirjiDate;
    System.Globalization.CultureInfo        cultureInfo = new System.Globalization.CultureInfo("ar-SA",false);
    System.DateTime                         dt;
    STRExtendedDT                           dateString;
    ;
 
    dt = this.ExpieryDate;
    hirjiDate = cultureinfo.get_DateTimeFormat();
    hirjiDate.set_Calendar(Calendar);
    dateString = dt.ToString("dd/MM/yyyy", hirjiDate);
 
    return dateString;
}

You will get :) :

Hirji date

Dynamics AX 2012 Event

Recent Posts

Tags

Archives

Random Testimonial

  • ~ Ehab Elmetwally, ERP Business Unit Manager at Alfanar IT

    07b0494"I worked with and managed amer for nearly 1 year and a half. A real technical consultant with tangable expierience. His capabilities and attitude enabled him to be of a big benefit to our departement. I recommend him as a professional technical consultant"

  • Read more testimonials »