Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my vb.net application, I import excel sheet data into my sql server database. Date format in excel is set as dd/mm/yy and in my database , i have set my datatype to 'date'. The problem is my database shows date as well as time. for eg: 11-10-2014 00:00:00. How can i make my database store only date and not time?
Posted
Comments
Sinisa Hajnal 11-Dec-14 2:22am    
You can't. It is datetime field. What you can is format the output before showing to the user.
hlsc1983 11-Dec-14 8:57am    
how can i do it vb.net? i need to display the data in a listview control

It depends upon your version of SQL Server, but you may wish to define the column type as DATE instead of DATETIME.

 
Share this answer
 
Comments
Maciej Los 11-Dec-14 14:58pm    
+5
You can store only date by having the datatype as Varchar(8), But that is not advisable , Instead store it as date and format it as per your requirement use date format option.

Check this

SQL Server Functions that helps to convert date and time values to and from string literals and other date and time formats.[^]
 
Share this answer
 
v2
Comments
Maciej Los 11-Dec-14 14:58pm    
It's bad idea to store date data as varchar datatype. It might be the reason of several issues.
My vote of 1.
Shweta N Mishra 12-Dec-14 3:20am    
I understand thats why said that its not advisible. :) and store it as date only.

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