Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert date From Gregorian to Hejiri

49 views
Skip to first unread message

JoHn

unread,
Dec 22, 2009, 8:31:01 AM12/22/09
to
Hi all,

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

Willy

unread,
Dec 22, 2009, 2:52:01 PM12/22/09
to
Hi 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)

JoHn

unread,
Dec 23, 2009, 2:46:01 AM12/23/09
to

Thanks will...

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

Willy

unread,
Dec 23, 2009, 2:08:04 PM12/23/09
to
Hi 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,

Amer

unread,
Dec 24, 2009, 6:24:01 PM12/24/09
to
Hi John,

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

JoHn

unread,
Dec 28, 2009, 5:18:01 AM12/28/09
to
Wow Willy.... Nice on... This one solved my problem... Thanks a lot. :)

JoHn

unread,
Dec 29, 2009, 4:39:01 AM12/29/09
to
Hi Amer,
I saw your article in your blogspot and its very interesting...
my questions is how can i run the sql statement syntax within the axapta? in
X++ way?

we are currently using dynamics AX 4.0
Please help me...

Thanks in advance!

0 new messages