I need to convert a gregorian date to Hejiri date and vice versa..
Please help me how to do this in dynamics AX.
Thanks ,
John
I don't think you'll find a function for this in standard Ax.
But I'm sure you can use CLR Interop for this, by using the
System.Globalization.Calendar namespace. It allows you to create dates in
different calendars, with some tweaking you can use this for conversion as
well (I think).
System.Globalization.Calendar Calendar = new
System.Globalization.HijriCalendar();
System.DateTime DateTime;
;
DateTime = new System.DateTime(year,month,day,Calendar)
Good luck,
Willy (blog at http://dynamics-ax-live.blogspot.com)
Im trying this code but seems not working...
System.Globalization.Calendar Calendar = new
System.Globalization.HijriCalendar();
System.Globalization.DateTimeFormatInfo HijriDTFI;
System.Globalization.CultureInfo cultureInfo = new
System.Globalization.CultureInfo("ar-SA",false);
System.DateTime dt;
int languageId;
;
dt = systemdateget();
HijriDTFI = cultureinfo.get_DateTimeFormat();
HijriDTFI.set_Calendar(Calendar);
HijriDTFI.set_ShortDatePattern("dd/MM/yyyy");
print dt.ToString("f", HijriDTFI);
pause;
could you please give me help on this?
Thanks in advance. :)
-John
I'm not an expert on the calendar matter, but your code doesn't look that
bad to me.
I tweaked it a little, like this:
System.Globalization.Calendar Calendar = new
System.Globalization.HijriCalendar();
System.Globalization.DateTimeFormatInfo HijriDTFI;
System.Globalization.CultureInfo ToCultureInfo = new
System.Globalization.CultureInfo("ar-sa",false);
System.DateTime dt;
;
dt=mkdate(23,12,2009);
HijriDTFI = ToCultureinfo.get_DateTimeFormat();
HijriDTFI.set_Calendar(Calendar);
HijriDTFI.set_ShortDatePattern("dd/MM/yyyy");
info(dt.ToString(hijriDTFI));
Maybe you can check out the ParseExact method as well.
If that doesn't do it, I'm sorry but can't help you out.
Kind regards,
Actually what I used to use is the "convert" function of SQL Server. Please
read the article I have posted recently in my blog about enabling Hijri date
in Dynamcis AX: http://blog.amer-ax.com/
Regards,
Amer
we are currently using dynamics AX 4.0
Please help me...
Thanks in advance!