web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Arabic Conversion of Date fields using plugin.

(0) ShareShare
ReportReport
Posted on by 432

Hi All,

I am trying to convert the Date fields in CRM to Arabic and store it in a text field. I have Successfully split the day, month and year into individual string variables but when i try to concatenate it, i am not getting the desired format as DD-MMM-YYYY instead my output is DYYYY-MMM-D.

SEE like this ۱٤-فبراير-۲٠۱٩

See my below code:

using System;
using System.Globalization;
using System.Text;
using System.Collections;
public static class Program
{
public static void Main()
{
string year = DateTime.Now.Year.ToString();
year = ConvertNumeralsToArabic(year);
string arabicDate = ConvertDateToArabic(Convert.ToDateTime(DateTime.Now.Date.AddDays(1)));
string a = ConvertNumeralsToArabic(arabicDate);
StringBuilder builder = new StringBuilder(arabicDate);
builder.Replace("YYYY", year);
string d = builder.ToString();
d = ConvertNumeralsToArabic(d);
string data = d;
char[] delimiters = new char[] { '-' };
string[] parts = data.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
ArrayList arr = new ArrayList();
for (int i = 0; i < parts.Length; i++)
{
arr.Add(parts[i]);
}
string day = arr[0].ToString();
string month = arr[1].ToString();
string year1 = arr[2].ToString();
string test = day + "-" + month + "-" + year;
Console.WriteLine(day);
Console.WriteLine(month);
Console.WriteLine(year1);
Console.WriteLine(test);
}
public static string ConvertDateToArabic(DateTime date)
{
return date.ToString("dd-MMM-YYYY", CultureInfo.GetCultureInfo("ar-ae"));
}
public static string ConvertNumeralsToArabic(string input)
{
return input = input.Replace('0', '٠').Replace('1', '۱').Replace('2', '۲').Replace('3', '۳').Replace('4', '٤').Replace('5', '۵')
.Replace('6', '٦')
.Replace('7', '٧')
.Replace('8', '٨')
.Replace('9', '٩');
}
}

Appreciate your help here.

Regards,

AKHIL

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    Have you tried this-stackoverflow.com/.../how-to-convert-english-date-to-arabic-date-in-net

    DateTime.Now.ToString("dd dddd , MMMM, yyyy", new CultureInfo("ar-AE"));

    Hope this helps.

  • Akhil101 Profile Picture
    432 on at

    Hi Ravi,

    Thanks for your response!

    I tried with that but i am getting the result as dd-YYYY-MMM but i want the result as DD-MMM-YYYY. This is the reason i split the day, month and year into different string variables then tried to concatenate it still not getting the desired result.

    Regards,

    Akhil

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    I tried it again and it turns out that be defaykt when you are adding the MMM (i.e. month name), it is putting the month name at last even if you concatenate dd-MMM-yyyy.

    It works fine with the number- ConvertNumeralsToArabic(DateTime.Today.ToString("dd-MM-yyy",new CultureInfo("ar-ae")))

  • Verified answer
    Akhil101 Profile Picture
    432 on at

    I got the solution ravi. Hurrayyyyyy :) :)

    its like you need to use Right to Left while concatenating the string variables!!!!!!!!!!!!

    Below is the code:

    public static string ConcatBidirectionalWithJoin()

    {

    string IdWithSubType = "طائرات هليكوبت";

    string MiddleString = "(100252575";

    string EndString = "@vk.com";

    string ltr = ((char)0x200E).ToString();

    return string.Join(ltr, IdWithSubType, MiddleString, EndString);

    }

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Great :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans