Click here to Skip to main content
15,887,888 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am inserted in a date value which is in the form of 9/5/2011 while inserting, on displaying on the other page it showing as 9/5/2011 10:10:11. I don't want to display the time.

Any idea? Please help.
Posted
Updated 5-Sep-11 20:58pm
v2

Depending in what control you show the value you can possibly:
- format the date in the control
- you can format the date before showing it for example using DateTime.ToShortDateString Method [^]
- you can remove the time portion when you fetch the data from the database for example by casting the value to date using using CAST or CONVERT[^] (if this is Sql Server).
 
Share this answer
 
Comments
Abhijit Jana 6-Sep-11 4:07am    
Yes, ToShortDateString is simple and best ! +5
Wendelius 6-Sep-11 6:29am    
Thanks Abhijit :)
Use DateTime.ToString[^] like yourDate.ToString("d/M/yyyy") for showing the date.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900