I am trying to select the DeliveryDate from sql database as just date. In the database, i am saving it as datetime format. How is it possible to get just date??
SELECT Subject, DeliveryDate
from Email_Administration
where MerchantId =@ MerchantID
03/06/2011 12:00:00 Am just be selected as 03/06/2011..
Thanks alot in advance! :)
6条答案
按热度按时间arknldoa1#
After perusing your previous questions I eventually determined you are probably on SQL Server 2005. For US format you would use style 101
p4tfgftt2#
try the following as there will be no varchar conversion
mrphzbgm3#
With SQL server you can use this
with mysql server you can do the following
SELECT * FROM my_table WHERE YEAR(date_field) = '2006' AND MONTH(date_field) = '9' AND DAY(date_field) = '11'
chhkpiq44#
mklgxw1f5#
Create a function, do the conversion/formatting to "date" in the function passing in the original datetime value.
Now call the function from the view:
yiytaume6#
if you are using SQL Server use convert
e.g.
select convert(varchar(10), DeliveryDate, 103) as ShortDate
more information here: http://msdn.microsoft.com/en-us/library/aa226054(v=sql.80).aspx