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

  • ~ Mohammad A-Awami, Dynamics AX Specialist at WorleyParsons

    AlAwami"I worked with Amer for WorleyParsons. I found him very cooperative. He is able to help me in a lot of issues that related to ax. His ability to solve the problems is fascinating me. It is so fast and done on the best practice. His ability on business analysis and implantation are done on the best methods."

  • Read more testimonials »