reza
reza

Reputation: 23

query for convert date time to persian calender

i have a database with a table name student and 4 columns Name,family,date Born in application i have 3 text box and data gridview date entered in database in date time "2013-05-01" but i wnt show in data gridview in persian calender

Upvotes: 0

Views: 523

Answers (1)

Rasool Ghafari
Rasool Ghafari

Reputation: 4278

You can use from using System.Globalization from your code behind as you see below:

public string Date(string yourDate)
{
    PersianCalendar pdate = new PersianCalendar();

    DateTime nT = new DateTime();

    nT = DateTime.Parse(yourDate);

    string s = String.Format("{0}/{1}/{2}", pdate.GetYear(nT), pdate.GetMonth(nT), pdate.GetDayOfMonth(nT));

    return s;
}

Upvotes: 1

Related Questions