Convert Date Format from mm/dd/yyyy to dd/mm/yyyy

Hi,

In my Web application I need to show the date in dd/mm/yyyy format to the user. In my application i am showing the date in various forms e.g. In GridView, In dataGrid, In combo, In textBox etc.

how will it be possible?

 

Thanks

Priyank Kansal 

0
priyank
5/10/2007 10:00:24 AM
asp.net.localization 2171 articles. 0 followers. Follow

7 Replies
2619 Views

Similar Articles

[PageSpeed] 10

dear,

try this, String.Format("{0:yyyy-MM-dd HH:mm:ss}", Now)

it will return string like "2007-05-01 12:30:01"

 

set format as per your need. 

 


regards,
Niraj sikotara.


<!-- Search before you scramble. --!>
0
niraj_d418
5/10/2007 11:44:38 AM

actually pretty, I am using hundreds of pages in my web application. Now it is very difficult to change the format of each and every control and line manually.

is there have any way to do this for whole application in one go?

 

 

regards

Priyank Kansal 

 

 

0
priyank
5/10/2007 11:58:34 AM

Hi,

Sure, there's a simpler way to go!

Just place a <pages culture="Auto" /> element in your Web.config (under the system.web element) and each user will get the dates formatted to their own preferences.

If you want all users to get a dd/mm/yyyy format, just write <pages culture="fr-FR" /> for instance...

Hope this helps,

Arnaud
 


Microsoft .net Training and Consulting
http://www.dreamdotnet.com/
Microsoft .net 3.0 Training and Consulting
0
aweil
5/11/2007 5:12:05 AM

Hi,

I've problem too, regarding date format.

Arnaud, I still have an error ;

Parser Error Message: Unrecognized attribute 'culture'. Note that attribute names are case-sensitive.

Source Error:

Line 34:   <roleManager enabled="true" />
Line 35:   <compilation debug="true" strict="false" explicit="true"/>
Line 36:     <pages theme="Default" culture="Auto">
Line 37:       <namespaces>
Line 38:         <clear/>

I put the code on web.config at root.
Am I miss something here ?

Thank you all

0
Helgeduelbeck
5/13/2007 2:36:59 PM

Ooops, I'm sorry...

The right thing to write in the Web.config is:

 
<system.web>
        <globalization culture="auto" uiCulture="auto" enableClientBasedCulture="true"/>

....
 


 


Microsoft .net Training and Consulting
http://www.dreamdotnet.com/
Microsoft .net 3.0 Training and Consulting
0
aweil
5/13/2007 8:20:24 PM

Yeah,

Thank you a lot ...

And I put addtional line : HtmlEncode = "False"
For my gridview to display the right formatdate.

<asp:BoundField DataField="Start" DataFormatString="{0:dd-MMM-yyyy}"
HeaderText="Start"
SortExpression="Start"
HtmlEncode="False" >
<ItemStyle Wrap="False" />
</asp:BoundField>

 Thanks
0
Helgeduelbeck
5/15/2007 2:08:09 AM

You're welcome, I'm glad I could help!

 Just wondering: if you use a DataFormatString for the date, it won't take into account the culture to display the date, so it won't vary for users with other languages... But that may be what you want...

Best regards,

Arnaud 


Microsoft .net Training and Consulting
http://www.dreamdotnet.com/
Microsoft .net 3.0 Training and Consulting
0
aweil
5/15/2007 7:29:58 AM
Reply:

Similar Artilces:

How To Convert dd/mm/yyyy date into mm/dd/yyyy format
Hi My Application recieves date in dd/mm/yyyy format.But I want to convert into dd/mm/yyyy format.If is there any format for that please help me.Debabrata Pattanaik DateTime datenow = DateTime.Now;DateTime convertdate = Convert.ToDateTime(datenow.ToString("mm/dd/yyyy"));Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET now.toString("mm/dd/yyyy")  Hi ,Another way is :-   now.tostring("d");Go to page and change culture property of the page to en-us.Not b...

US date format dd/mm/yyyy gets converted to mm/dd/yyyy
Dear All,I got an sql query that I pass to sql server as a string. I pass a date as a string in the query and compare it to a date in a table.The trouble is somewhere in the process I get ‘01/04/2006’ turned into ‘04/01/2006’ I do understand mm/dd/yyyy is the US date format. The problem is I pass in dd/mm/yyyy and I compare it to dd/mm/yyyy, however it is dd/mm/yyyy gets compared to mm/dd/yyyy for some reason.I tried the 3 variations below, but none works ok, suggesting that the conversion takes place somewhere #in between’. Can someone tell me how to solve this?<code>Dim myDat...

How to convert the date from UK format dd/mm/yyyy to mm/dd/yyyy before sending it to database
I am having a problem with the dates. my application will be used in USA and also in UK. if the date format is like mm/dd/yyyy then i don't have no problem passing it to stored proc to update or insert, but if i pass the date in UK format dd/mm/yyyy i am getting the following error: (String not recognized as date and time) I am getting the following:  txtNeedDate.PostedDate = "31/01/2007"  i want to use a condition, if the date format is in UK then change it to "01/31/2007" before i pass it to database via storted proc. Please does any one know how i can convert the above dat...

date format being changed from mm/dd/yyyy to mm/dd/yyyy hr:mm am
Hello All,i am importing a excel sheet into a sql database. in the excel sheet i have column whose date format is mm/dd/yyyy (07/16/2008). but when ever i import the sheet into the database, its automatically getting changed to 07/16/2008 12:00 am. any idea how i can retain the excel format. any help would be highly appreciated.Thanks  That is the way in SQL Server's datetime data type before we have SQL Server 2008 available. You can format the datetime to remove the time part in your query or format it from client side. Let us know if you need more help.Limno Hello Sir,can you...

Formatting the Date from dd/mm/yyyy to mm/dd/yyyy
Hi,  I have a textbox in which the date is coming from a javascript calendar in dd/m/yyyy format but i want to change that into mm/dd/yyyy. I am trying to do like this DateTime dtProjectStartDate=Convert.ToDateTime(uxdate.Text);Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); dtProjectStartDate = Convert.ToDateTime(dtProjectStartDate); but it is giving me the error "string was not recognised as a valid datetime. " and i have tried this also but getting the same error. Please help me.DateTime.ParseExact(uxdate.Text...

Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
I am very new to asp.net (started this week)  I have the following line FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2) which is currently displaying the date as MM/DD/YYYY when I need YYYY/MM/DD to suit my database (MySQL)  How can I go about formatting the date to suit my needs?  Thankyou With FormatDateTimeyou have a limited range of formatting options see http://msdn2.microsoft.com/en-us/library/a912f2a0(VS.80).aspxChange FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2)to dsEdit.FieldValue("BDateStart", Container).ToString("yyyy/MM/dd") &...

How to change the format of Date from dd/MM/yyyy -> yyyy/MM/dd
The Code is-protected void btnSave_Click(object sender, EventArgs e) {DataSet ds = new DataSet();SqlDataAdapter adp = new SqlDataAdapter("select max(Int_MemberShipNo) as mem_no from M_CA", con); adp.Fill(ds);if (ds.Tables[0].Rows[0][0].ToString() == "") { mem_no = 1; } else {mem_no = Convert.ToInt16(ds.Tables[0].Rows[0][0]) + 1;Session["mem_no"]=mem_no.ToString(); } DateTime dt_dob = Convert.ToDateTime(txtDOB.Text); DateTime dt_dom = Convert.ToDateTime(txtDOM.Text);if (RadioButtonList1.SelectedItem.Text == "Home") {i = "H"; ...

How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy
I have the date in textbox in this format(dd/MM/yyyy), how can i convert textbox1.text date to MM/dd/yyyy. Thank you very much for the information.    TextBox1.Text.ToString( "MM/dd/yyyy" ); Hi, you need to set specific cultrue to parse string to dateTime, and then output desired time format. However I have one simple way to swith day and month.    TextBox1.Text = "08/30/1999";   DateTime temp;    temp = Convert.ToDateTime(TextBox1.Text);   TextBox1.Text = temp.ToString("dd/MM/yyyy"); // or "MM/dd/yyyy" &n...

Daterange Picker Calendar control Without clicking Start Date and End Date Separately ( dd/mm/yyyy-dd/mm/yyyy format
Hello all,  Plz Suggest me the Daterange Picker Calendar control . so that i can select a range of date (after clicking on button javascipt calendar will be executed) and date will appear in the format dd/mm/yyyy-dd/mm/yyyy in listbox (like without cliking for Start Date and End Date Separately)  Swati Jain   Check this:http://www.codeproject.com/useritems/DateRangePicker.asp NC... Some of the third party Calendar controls allow multiple selections. If they support the ability to just click on the start and then end dates to form a range, or can limit the u...

date format dd/mm/yyyy in aspx pages but mm/dd/yyyy in access db
I'm working with asp.net 2.0 and having the problem that my date/time objects are stored in american format (mm/dd/yyyy) in my access database, but on my page they are in european format (dd/mm/yyyy).How do i get the dates in my database to be in european format.The code follows, the problem is that when i select a date in my calender obj and press the button1, the date is forwarded to the SqlDataSource InsertCommand. (in debug mode i can see that the date that is passed to the SqlDataSource is still in the correct format).In my database i can see that the date has gone from 01/10/2005 to 10...

How to change date format from mm/dd/yyyy to dd/mm/yyyy in sql server 2005 express edition
I have a page where i m showing some data and date which is in mm/dd/yy format in detail view,but i want to show date in dd/mm/yy format. I tried but it didn't work.What should i do. Please help me out. ThanksWeb DeveloperPune,India Hi here is the sample query. SELECT CONVERT(VARCHAR(20), GETDATE(), 103)Hope this will work.  Valentine Day Special SongASP.NET ListView Control  I don't think you need to change the representation of dates in Sql Server, but only how they are presented in the DetailsView.  For that you can use a dataformatstring of "{0:...

How do i format dd/MM/yyyy back to MM/dd/yyyy?
i've a webform that allow people to enter a date in the format of "dd/MM/yyyy" and i've a regular expression to validate it. But problem is now i have to insert this date into the db. And when i do so, it keep saying "Cast from string "30/01/2001" to type 'Date' is not valid." when i try to insert it using a function like: Line 488: If buttonSaveItem.CommandArgument = "Add" Then Line 489: InvoiceStruct.AddInvoice( _ Line 490: CType(textboxInvoiceDate.Text, Date), _ Line 491: textboxInvoiceCustomer...

how can i convert the string from "21/12/2005" which is in dd/MM/yyyy format to MM/dd/yyyy
hi all i would like to convert a string that is when user type in the textbox let say "21/12/2005" in dd/MM/yyy and convert to MM/dd/yyyy . how do it do that ?Karen Dim dt As DateTime = txtInput.Text txtOutput.Text = dt.ToString("MM/dd/yyyy")think this should do it Dim strDate(3) as String Dim strDateNewFormat as String strDate = txtDate.text.split("/"c) strDateNewFormat = strDate(1) & "/" & strDate(0) & "/" & strDate(2) ThanksDinuj Nath Try this link for sample code.  Hope this helps.   http://msdn.microsoft.com/library/default.asp?url=/libr...

save date in database n retrieve with format dd\mm\yyyy not mm\dd\yyyy display to main.aspx
I need input from user using text box which is like this dd mm yyyy and how can i manipulate so that i can save in db with default format mm dd yyyy? HI, you can use the format method of the textbox and specify the date format in that. I havent tried but it should work. Have a Great DayRegardsRamu can u provide me with example so that i can see clearly what ur point...tq Hi, If possible ask the user to enter the date in dd-mmm-yyyy fromat so that, there won't be any confusion between month and date when you save your record in db. otherwise, you can use format functi...

Web resources about - Convert Date Format from mm/dd/yyyy to dd/mm/yyyy - asp.net.localization

File:Convert to SVG and move to Commons.svg - Wikipedia, the free encyclopedia
As a courtesy (but not a requirement), please e-mail me or leave a note on my talk page if you use this image outside of Wikipedia. Thanks! As ...

Facebook Co-Founder Dustin Moskovitz Sells 450K Shares, Converts 7M More
The great Facebook stock sale frenzy continues on with a report that Co-Founder Dustin Moskovitz unloaded 450,000 shares in the social network ...

Facebook Announces “App2User” Liquidity Program for Merchants to Convert Rewards Points into Credits
... for Credits, just announced a new Credits program called “App2User,” designed to enable merchants and loyalty program operators to convert their ...

How to Convert Leads Into Buying Customers - The 9 Step Sales Process EVERYONE Should Use
... School of Business in Toronto on the topics of Sales and Entrepreneurship. I shared with them the sales process that I find How to Convert Leads ...

Bitcoin : Should I convert my savings to Bitcoin?
Answer (1 of 7): You should think of this question as "Should I invest all my savings in Bitcoin?", and not "Should I have my savings denominated ...

Convertizo 2 - Convert Units and Currency in Style on the App Store on iTunes
Get Convertizo 2 - Convert Units and Currency in Style on the App Store. See screenshots and ratings, and read customer reviews.

Catholics should not convert Jews, says Vatican, in push against anti-Semitism
... 50 years since the Vatican's repudiation of the concept of Jewish guilt for Jesus' death.  Vatican City: Catholics should not try to convert ...

Opinion: These 5 things made me a happy iPad Pro convert
... like I needed a bigger device. But after three weeks with my iPad Pro, several things have changed my mind, and I’m officially a happy convert ...

Today’s apps gone free: BlockBear, Stock Grader, PDF Smart Convert and more
Block ads and other annoying content, take the emotion out of investing, and convert almost anything into a PDF with todays collection of apps ...

How to convert your old VHS tapes to DVD with this software
Remember those old VHS tapes you have sitting in the corner? Convert them into DVDs with this affordable software so you can easily watch them ...

Resources last updated: 12/28/2015 10:30:26 PM