Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I define a Date field in my sql table and in sql management studio
dates store like this :
1390-10-14

i use a masked textbox by mask 0000/00/00
but in my datagrid c# this is show like:
14/10/1390

and when i use the code
C#
maskedtxt.text=datefield.tostring();

appear in textbox like above.

what's code need to correct this?
Posted
Updated 3-Jan-12 19:51pm
v2

try this
  string dttime = "12-31-2011 10:30:00";
            DateTime dt = Convert.ToDateTime(dttime);
string dttime=dt.Date.ToString("yyyy/MM/dd");
 
Share this answer
 
I prefer to store persian dates as string in database.
I utilize it for Presentation Layer (UI).
But I use an user defined method in C# to convert string to System.Globalization.PersianCalendar for Business Layer and some calculations.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900