Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, July 31, 2008 2:46 AM
hi all
i want to display only date in textbox not time
actually my date is coming from database and in database the type is datetime.
so it display me time too so is there any way in which i can show only date not time?
thanks
shweta
All replies (8)
Thursday, July 31, 2008 8:34 AM ✅Answered
its something like:
string myDate = MyDateTime.ToString("dd-mm-yyyy"); //this way should return the date as something like 12-01-2008
you can have the date formatting in many different ways, you could use slashes ("/") rather than dashes or use "dd-MMM-yyyy" which will return the date like 12-JAN-2008
Thursday, July 31, 2008 8:35 AM ✅Answered
DateTime dt1 = "From DB";
TextBox1.Text = dt1.ToShortDateString();
DateTime manipulation: http://www.blackwasp.co.uk/CSharpDateManipulation.aspx
Thursday, July 31, 2008 8:37 AM ✅Answered
In your Eva("somevalue") or Bind("somevalue") statements, you can add a format string property:
Bind( "someDateValue", "d" )
The "d" is a Standard Date and Time Format String in .NET.
Thursday, July 31, 2008 8:46 AM ✅Answered
use this
Now.Date.ToString()
Thursday, July 31, 2008 10:58 AM ✅Answered
Dim d As New Object
FormatDateTime(CDate(d).Date, DateFormat.ShortDate)
Thursday, July 31, 2008 3:16 PM ✅Answered
Hi
try this
DateTime time = DateTime.Now;
TextBox1.Text = time.ToShortDateString();
TextBox1.Text= time.ToString("dd/MM/yyyy");
Good Luck
Thursday, July 31, 2008 5:14 PM ✅Answered
If you are doing manually use following code,
<%#Eval("DateCreated", "{0:dd-MMM-yyyy}")%>
or if you are using GridView, go to the Edit column field and in the DataFormatString type {0:dd-MMM-yyyy} or you can type {0:d} too.
I hope this will help you,[Yes]
Thank you,
Thursday, July 31, 2008 8:32 AM
It depends on how you are getting the date to the edit. If you have access to the date object you can do it like this:
DateTime d = DateTime.Now;
TextBox1.Text = d.ToShortDateString();