473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DateTime.ToShortDateString

ad
I want to transfer a DateTime variable to string.
I use DateTime.ToShortDateString() to do that.
But if the date is 2006 May 23, I want to it transfer to 2006/05/23, not
2006/5/23.
How can I do?
May 23 '06 #1
3 33576
ad wrote:
I want to transfer a DateTime variable to string.
I use DateTime.ToShortDateString() to do that.
But if the date is 2006 May 23, I want to it transfer to 2006/05/23, not
2006/5/23.
How can I do?

ToShortDateString will use the system short date format which must be
yyyy/d/mm on your system.
You could change this to yyyy/dd/mm or call ToString("yyyy/dd/mm").

JB
May 23 '06 #2
DateTime.Now.ToString("yyyy/MM/dd");

"ad" <fl****@wfes.tcc.edu.tw> wrote in message
news:u4**************@TK2MSFTNGP05.phx.gbl...
I want to transfer a DateTime variable to string.
I use DateTime.ToShortDateString() to do that.
But if the date is 2006 May 23, I want to it transfer to 2006/05/23, not
2006/5/23.
How can I do?

May 23 '06 #3
"ad" <fl****@wfes.tcc.edu.tw> wrote:
I want to transfer a DateTime variable to string.
I use DateTime.ToShortDateString() to do that.
But if the date is 2006 May 23, I want to it transfer to 2006/05/23, not
2006/5/23.
How can I do?


You can pass in a format to ToString() on the Date:

---8<---
DateTime.Today.ToString("yyyy/M/d")
--->8---

-- Barry

--
http://barrkel.blogspot.com/
May 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nugnet | last post by:
Hi, I have an ASP.NET web application that I want to be locale sensitive. I set my regional options to be English (United States) and rebooted my machine (normally have English(United Kingdom...
4
by: Vinitha | last post by:
Hi, I 've ("9/27/2003 12:11:31 PM") this value in database . i need to get only this value ("9/27/2003 " ) .How will i format it to get this value? It will be helpful if some one could point...
1
by: aaa | last post by:
Hi I am trying to bind Text property of label control to datetime object (attribute from typed dataset). The problem is that I want only to show date part. Currently I use following code: ...
6
by: Paulb1us | last post by:
I want to set a DateTime field to Null before passing it to the DB //First I check to see if anything is in this datarow column, because sometimes we have no data. DateTime dt; if (...
1
by: Bill Burke | last post by:
VS .Net 2003 C# Using DateTime.Now to capture System date and time and displaying it in a user control (label). It works fine, but really only want to display the date (not the time). Can anyone ...
3
by: ad | last post by:
I use a string sDate to fetch a SmallDateTime field form SQL Server and the result is :"2005/12/12 ¤W¤È 12:00:00"; How can I get the Date part from the string? or can I get the Date part from...
2
by: tshad | last post by:
I can't seem to get the Date portion of a datetime variable put into a string: I tried: DateTime dateTime; dateTime = Convert.ToDateTime(dr).Date; stemp = Convert.ToString(dateTime); This...
11
by: Axel Dahmen | last post by:
Hi, I'm working in a team developing an international website. When I set the page's CultureInfo to Hungarian (hu-HU) then the RangeValidator doesn't seem to be able to parse a TextBox's date...
2
by: Jesus | last post by:
Hi! I'm migrating a web application (ASP.NET) from Framework 1.1 to Framework 2.0. I have a problem with that, and I didn't found a solution changing something in web.config or something like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.