in my program i want to get date as dd/mm/yyyy and when storing convert as mm/dd/yyyy
for me while inserting it only accepts as mm/dd/yyyy but i want to give input as dd/mm/yyyy how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net give me clear description
Simple store the date in a datetime column in SQL Server, you can't store it in any particular format. Just pass the paramterer as a System.DateTime value.
If you want to select the date in the format dd/mm/yyyy in SQL Server: SELECT CONVERT(VARCHAR(10), GETDATE(), 101)
To convert the value from your textbox into a DateTime:
DateTime dt;
DateTime.TryParse(textbox1.Text, out dt);
jesunathan
Member
31 Points
51 Posts
how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 11:59 AM|LINK
Hi every one
in my program i want to get date as dd/mm/yyyy and when storing convert as mm/dd/yyyy
for me while inserting it only accepts as mm/dd/yyyy but i want to give input as dd/mm/yyyy how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net give me clear description
i get input in textbox1
mm10
Contributor
6409 Points
1184 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 12:06 PM|LINK
Simple store the date in a datetime column in SQL Server, you can't store it in any particular format. Just pass the paramterer as a System.DateTime value.
If you want to select the date in the format dd/mm/yyyy in SQL Server: SELECT CONVERT(VARCHAR(10), GETDATE(), 101)
To convert the value from your textbox into a DateTime:
DateTime dt;
DateTime.TryParse(textbox1.Text, out dt);
Shankar_ss
Participant
1270 Points
279 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 12:06 PM|LINK
Try this:
hope it helps.
string DateString = "22/04/2011";
DateTime date = new DateTime();
date = DateTime.ParseExact(DateString, "dd/MM/yyyy");
string NewDateString = date.ToString("MM/dd/yyyy");
Shankar
shivalthakur
Participant
1839 Points
532 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 12:17 PM|LINK
little modification
IFormatProvider fp = new CultureInfo("es-ES"); string DateString = "22/04/2011"; DateTime date = new DateTime(); date = DateTime.Parse(DateString, fp); string NewDateString = date.ToString("MM/dd/yyyy"); Response.Write(NewDateString);Response.Write("Success");
Best Of Luck
Shival Thakur
jesunathan
Member
31 Points
51 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 12:29 PM|LINK
At the run time i want to get date in textbox as 21-03-2012 that is dd/mm/yyyy and stores in database
but for me it only stores when input given as 03-21-2012 that is mm/dd/yyyy otherwise it shows an error (format error)
how to solve this
tdmca
Contributor
2396 Points
661 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 12:31 PM|LINK
change DateTime format of your system from ControlPanel->Ragional and Language->Additional Setting and restart
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 12:42 PM|LINK
How to solve this? You can start by looking at the previous answers.
jesunathan
Member
31 Points
51 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 12:49 PM|LINK
Where should i get the textbox value in those perioves examples
when doing shows error as (String was not recognized as a valid DateTime)
mm10
Contributor
6409 Points
1184 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 12:56 PM|LINK
Try this:
DateTime date = DateTime.ParseExact(TextBox1.Text, "dd-MM-yyyy", null);
tdmca
Contributor
2396 Points
661 Posts
Re: how to get dd/mm/yyyy and stores as mm/dd/yyyy in asp.net
Apr 12, 2012 01:20 PM|LINK
follow what i have suggested sure shot formula