Click here to Skip to main content
15,887,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i m storing a date in sql server it automatically adds "12:00:00 AM" when retrieving it... i wanna know how to stop it?????plz....any help.......
Posted
Updated 7-Aug-12 0:01am
v2

Data type of DATE or DATETIME will append the time also. If you want to avoid the time then take data type of the column as VARCHAR and CAST it whenever required.

--Amit
 
Share this answer
 
Comments
Sandeep Mewara 7-Aug-12 13:32pm    
Exactly. 5!
http://www.codeproject.com/Answers/432559/DateTime-to-date-Only-But-In-DateTime-type-only#answer1
_Amy 7-Aug-12 14:35pm    
Thank you sandeep. :)
You mean in the asp.net, it automatically appends 12:00 AM?

Then try this.

C#
date1.ToShortDateString();


Here date1 is my datetimeobject.

or if its in sql server, then

SQL
select Convert(varchar(10),date1,101) from tbl_Temp
 
Share this answer
 
v3
Comments
Himu from Orissa 7-Aug-12 5:53am    
i m using calender extender , in which date is displayed in a textbox and from textbox i m sending it to database, so where to use the method ToShortDateString()
Santhosh Kumar Jayaraman 7-Aug-12 6:07am    
If you dont want 12:AM in UI, then always use Toshortdatestring with datetime
Santhosh Kumar Jayaraman 7-Aug-12 5:56am    
textbox.Text= Calendar1.SelectedDate.ToShortDateString();
set column datatype as date in sql server. as your problem shows currently it is date time.
 
Share this answer
 
Comments
Himu from Orissa 7-Aug-12 5:37am    
i have taken datatype as "date"

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