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
MuthuMari MPosted Apr 28, 2012, 5:56 AM
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"
Lajapathy ArunPosted Apr 28, 2012, 5:47 AM
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
theLizardPosted Apr 28, 2012, 8:00 PM
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);
Kunal VaishyaPosted Apr 28, 2012, 6:08 AM
Like Employee Table
Id Numeric
Name Varchar(20)
DOB DateTime
Like This
Select Id, Name, select convert(varchar, DOB, 105) As DateOfBirth From Employee