Microsoft Dynamics AX Blog
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:
By doing this, you will have a drop down list in the User Options shown in the General tab like the following:
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:
-
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.
-
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:
This is the result:
Search the site
Dynamics AX 2012 Event
Recent Posts
- D365FO | Cannot Connect to SQL Server Database on Your Cloud Test Machines
- Intro to Microsoft Dynamics AX in Arabic – سلسلة حلقات مايكروسوفت داينامكس إيه إكس بالعربية
- Microsoft Dynamics Launch – Sunday, 24th February – Intercontinental Hotel, Riyadh
- Files of Our AX Brains Dec 2012 Event
- It was a great day!
- Tomorrow is the day for our Dynamics AX Brains Technical Seminar
- Dynamics AX Brains December 2012 Technical Seminar
- Windows Server 2012: Built from the Cloud Up
Tags
Archives
- October 2019 (1)
- January 2014 (1)
- February 2013 (1)
- December 2012 (4)
- September 2012 (2)
- December 2011 (2)
- November 2011 (3)
- July 2011 (3)
- June 2011 (4)
- May 2011 (3)
- April 2011 (4)
- March 2011 (12)
- February 2011 (2)
- January 2011 (3)
- December 2010 (1)
- November 2010 (1)
- October 2010 (5)
- August 2010 (1)
- July 2010 (3)
- June 2010 (4)
- May 2010 (5)
- April 2010 (1)
- March 2010 (9)
- February 2010 (4)
- January 2010 (4)
- December 2009 (11)
- September 2009 (1)
- August 2009 (1)
- July 2009 (2)
- September 2008 (1)
Random Testimonial
- ~ Ahmad Al-Shanshoury, Senior Dynamics AX Consultant at Al-Fanar IT
"I am pleased to be able to write this recommendation for Mr. Amer Atiyah, I was lucky to work with Amer during our implementation of Dynamics AX at AlOthaim company. Since the day one, I know him as an energetic and goal-oriented person Amer demonstrated a strong work ethic and a dedication to success. His efforts have produced high quality results time and time again.His extraordinary ability to analyze problems and outline necessary courses of action was invaluable, simply I can see Amer innovative, creative, intelligent and ambitious, in addition of his powerful Technical background. Seldom have I been able to recommend someone without reservation. It is a pleasure to do so in the case of Amer"
- Read more testimonials »
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.
Hi Amer – this is really helpful.
Could you please confirm if I give this to my developer, he’d be able to use your methods to handle Finance module customizations that include fiscal year calculations for reconciling etc.? The objective is to be able to provide a Public Sector organization in Saudi with Hijri Calendar controls to manage Finance, HRM and Project Accounting modules in AX.