but when i will store record in dd-mm-yyyy format and when i will retrive record from database it will also display record in mm-dd-yyyy but i want to record in dd-mm-yyyy and another thing is getdate() will display current dat in dd-mm-yyyy format |
Loading

Lajapathy ArunRank #354 · 7K reputationPosted Apr 28, 2012, 1:47 AM EDT
You can use DateTime.TryParseExact , here you can set format and get as Dattime obj and then what format you want you can get here.
http://www.dotnetperls.com/datetime-tryparseexact
Thanks
Lajapathy Arun
MuthuMari MRank #5,738 · 288 reputationPosted Apr 28, 2012, 1:56 AM EDT
In db it will store mmm-dd-yyyy. but after retrieving the data from db you have to use like this
Format("dd-MMM-yyyy")
thanks.
If this post is useful then mark it as "Accepted Answer"
Kunal VaishyaRank #990 · 2K reputationPosted Apr 28, 2012, 2:08 AM EDT
Like Employee Table
Id Numeric
Name Varchar(20)
DOB DateTime
Like This
Select Id, Name, select convert(varchar, DOB, 105) As DateOfBirth From Employee
theLizardRank #1,079 · 1.8K reputationPosted Apr 28, 2012, 4:00 PM EDT
When done this way you simply say DateTime dt = dbFieldDate and it will be shown for the region you are in determined by the system date time locale.
When assigning a date to a string variable textBox1.Text = dt.ToString("dd-mm-yyyy");
or textBox1.Text = dt.ToString("dd-mm-yyyy" hh:mm:ss);