Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have created a table with name and date. Their respective data types are varchar and datetime.

If I insert date in web page, I am getting time also i.e., if I insert 11/11/2012 in web page, in sql table, I am getting its record as 11/11/2012 12:00:00.

I need to get that record as only date but not date time in sql table, How can I do this??

Thanks. .
Posted

your column description either chose only "date" type

otherwise use Convert(varchar,mydateColumn, XYZ)as mydateColumn

replace xyz with a number between 100 to 125
 
Share this answer
 
Change your table definition as in for date, use data type only "date" instead of "datetime"..
 
Share this answer
 
You can format the date in your query

SQL
SELECT convert(varchar, getdate(), 103) --date in dd/mm/yyyy format


Refer this link[^] for different date formats in sql.
 
Share this answer
 
hi,

use below,

when you retrieve data from table that time use below format for retrieval:
CONVERT(VARCHAR(8),GETDATE(),101) AS DateOnly


this will help you..




happy coding..
 
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