Convert From Georgian Date (English Date) To Arabic Hijri Date (Umm Al Qura)

I found a good question on the newsgroup answered by David Musgrave, one of the solution’s steps was the conversation format between Georgian Date (Standard Date) and Hijri Date from the following link:

http://www.microsoft.com/middleeast/msdn/arabicsupp.aspx#31

Using Hijiri Calendar


You can set a culture to one of its supported calendar types. For example, the Arabic cultures support the Hijri calendar, so, you can set the Arabic culture calendar to Hijiri calendar. As mentioned before, the CultureInfo.Calendar is a read-only property which gets the current calendar, but can’t be changed. Instead, you can specify the calendar of the DateTimeFormat.Calendar of the CultureInfo, as in the following code :

// Create a CultureInfo object for Saudi Arabia.
CultureInfo sa = new CultureInfo(“ar-SA”);
sa.DateTimeFormat.Calendar = new HijriCalendar();

You can perform any operation with Hijri dates in the same way, such as displaying Hijri and converting Hijri from/to Gregorian or other calendars.
The following example converts a date from Gregorian to Hijri and displays it:

DateTime dt;
System.Globalization.DateTimeFormatInfo HijriDTFI;
try
{
  dt = Convert.ToDateTime(“12/26/2001”);
  HijriDTFI = new System.Globalization.CultureInfo(“ar-  EG”,false).DateTimeFormat;
  HijriDTFI.Calendar = new System.Globalization.HijriCalendar();
  HijriDTFI.ShortDatePattern = “dd/MM/yyyy”;
  Console.WriteLine(dt.Date.ToString(“f”, HijriDTFI)};
}
catch(Exception ex)
{
  Console.WriteLine(ex.Message);
}

The output is:

clip_image001

The following example converts date from Gregorian to Hijri using two different methods:

DateTime dt = new DateTime(1422, 1,1, new HijriCalendar());
Console.WriteLine(dt.Date.ToString());

The output is:
      26/11/2001 or 11/26/2001 (according to your current culture settings)

 

Hope this helps.

Regards,

Mohammad R. Daoud
MCP, MCBMSP, MCTS, MCBMSS
Software Development Manager
+962 – 79 – 999 65 85
Great Package For Business Solutions
daoudm@greatpbs.com
http://www.greatpbs.com/

Advertisements

About Mohammad R. Daoud
Mohammad R. Daoud has been working as a Microsoft Dynamics GP consultant since 2004. His career path started with version 7.5; he studied every single tip of the application technicalities and did allot of successful implementations that includes functional consultations, analysis, and custom development projects. He holds a graduate degree in Computer Science and currently he is pursuing MBA degree in Accounting. In January 2007 he was nominated to the Microsoft Most Valuable Professional (MVP) certificate and was certified in April 2008 due to his online contributions in the Dynamics Community (Dynamics GP Newsgroups, Forums, User Groups and his blog: http://mohdaoud.blogspot.com). Worth to mention that he was also listed as one of the Microsoft Dynamics Top 100 Most Influential People in 2009 by DynamicsWorld. And more... • Demonstrated Passion for MS Products through participating in beta testing for some product versions, an effective member of Microsoft Connect. • Talented in securing strong high quality relationships with premier customers, partners and sales teams passionately and profitably. • Dedicated to meeting the expectations and requirements of internal and/or external customers • Problem Solver – Uses systematic approach to uncover true problem(s) and practical solution and can marshal resources to solve problem! • Proven record of effective account management, including Account Planning, Opportunity Management, and Business Management Excellence and working as part of a larger virtual team • Successful in delivering high quality technical engagements in the enterprise Dynamics GP implementations area according to customer requirements. • Dedicated, Committed, Self Motivated, Creative and highly focused with excellent communication, Negotiation, presentation, Active Listening and Objection Handling skills. • Experienced in Profitable researches and studies including white papers and technical presentations.

2 Responses to Convert From Georgian Date (English Date) To Arabic Hijri Date (Umm Al Qura)

  1. Anonymous says:

    Thanks. Explains a lot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: