Blog

Microsoft Dynamics AX Thoughts

6

Hijri date in Dynamics AX

In Microsoft Dynamics AX 2009, Hirji calendar (the Islamic calendar) is not yet supported although Hirji date is there in the background of Dynamics AX 2009!

To enable the Hirji Calendar, you should modify some X++ code in the User Options form. To do so, go to: SysUserSetup –> Methods –> run and change the following blue code into the red:

Enabeling Hijri Calendar in User Options form in X++

Enabeling Hijri Calendar in User Options form in X++

  

  By doing this, you will have a drop down list in the User Options shown in the General tab like the following:

Hijri date in User Options form

With this options, you could clearly understand that Microsoft is putting something to enable the Hijri calendar. I have done some testing over this options. It looks that they’re using a middleware to convert the “actual” Gregorian date that is in the database so the user see the data in Hijri format. Unfortunately, I couldn’t complete the testing with successful results… it started to get me weird results. That’s why Microsoft is not yet supporting it.

  

Till Microsoft supports it, you could use a very easy to use function in the SQL server: convert(datetime,’12-22-2009′,102), 131)  

  

To solve the Hirji date problem, you could create a class with two methods:  

 

  1. One that takes a “date”  and returns a Hirji date after calling this SQL method: select convert(varchar,convert(datetime,’12-22-2009′,102), 131)  –try to run this in SQL Server to see the result. 
  2. Other that takes a Hijri date in an str format, and returns a date by executing this SQL code:  select convert(datetime,’22-01-1417′, 131) –try to run this in SQL Server to see the result

 By this, you could have the ability to show the user a StringEdit control that uses edit moeth to write a Hirji date and you save the result of conversion in the normal Gregorian date, like this:

Edit method to show Hirji date from Gregorian date

This is the result:

Hiji StringEdit control and DateEdit control

Hiji StringEdit control and DateEdit control

 

6 Comments to “Hijri date in Dynamics AX”

  • Hi,
    Thanks a lot for the post, really helpful…
    but for the class to be created, how can the SQL command be written in AX Code?

    Thanks

  • Hi!

    Try this code. This function basically takes a “normal” date as a parameter and returns the converted Hijri date as a string.

    server static str convertDateToStr(date strDate)
    {
    DictTable _dictTable;
    Connection _connection;
    Statement _statement;
    str _sql,strResultDate;
    ResultSet _resultSet;
    Enumerator enum, enum2;
    SqlStatementExecutePermission _perm;
    Str _tempStr;
    ;

    _tempStr = int2str(mthofyr(strDate)) + “-” + int2str(dayofmth(strDate)) + “-” + int2str(year(strDate));

    _Sql= “select convert(varchar,convert(datetime,’” + _tempStr + “‘,102), 131)” ;

    _connection = new Connection();

    _perm = new SqlStatementExecutePermission(_sql);

    // Check for permission to use the _statement.
    _perm.assert();
    _statement = _connection.createStatement();
    _resultSet = _statement.executeQuery(_sql);

    // End the scope of the assert call.
    CodeAccessPermission::revertAssert();

    _resultSet.next();

    strResultDate = _resultSet.getString(1);
    strResultDate = strLrTrim(strResultDate);
    enum = strSplit(strResultDate,” “).getEnumerator();

    if(enum.moveNext())
    strResultDate = enum.current( );

    enum2 = strsplit(strResultDate, “/”).getEnumerator();
    if(enum2.moveNext())
    {
    if(any2int(enum2.current()) < 10)
    strResultDate = “0″ + strResultDate;
    }

    return strResultDate;
    }

  • [...] a previous post, I descriped in deatils how to gte (and set) Hijri date in Microsoft Dynamics AX 2009. In that post [...]

  • [...] Hijri date in Dynamics AX [...]

  • thanks for your great posts
    Where we should write this edit method?

  • HI Mb:),

    In the form you want this field to be displayed in. :)

Post comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Dynamics AX 2012 Event

Recent Posts

Tags

Archives

Random Testimonial

  • ~ Ziad Yehia, ERP Business Consultant at NetWays

    no_thumb"I have one thing to say about Amer, When you have a tough Dynamics AX question that you are not able to answer; he is the person to call..."

  • Read more testimonials »

Posting tweet...

Powered by Twitter Tools