如何在没有时间的情况下独自获得约会部分 [英] how to get the date part alone without time
本文介绍了如何在没有时间的情况下独自获得约会部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT vm.RegistrationNo,
OilChangeOdometer,
OilChangeDate,
ServicingOdometer,
ServicingChangeDate,
TyreChangeOdometer,
TyreChangeDate,
driverid,
drivername,
licenseexpiry,
contact,
vh.Insurancestartdate,
vh.insuranceexpirydate,
vh.insurancecompany
FROM VehicleMaintance AS vm
FULL OUTER JOIN
vehicle_master AS vh
ON vm.RegistrationNo = vh.RegistrationNo
WHERE vm.RegistrationNo = @vehId
AND ((OilChangeDate BETWEEN @strFromDt AND @strToDt)
OR (ServicingChangeDate BETWEEN @strFromDt AND @strToDt)
OR (TyreChangeDate BETWEEN @strFromDt AND @strToDt));
在选择时,我仅需要来自oilchangedate的日期部分,而不需要时间部分.我会在报告中显示它,所以我只需要显示日期部分,而无需编辑和显示在查询本身中的时间部分.
while selecting i need only the date part from only oilchangedateand not the time part. iam displaying it in an report ,so i need only the date part to be displayed not the time part pls edit and show in my query itself.
推荐答案
:
http://blog .sqlauthority.com/2007/06/10/sql-server-retrieve-select-only-date-part-from-datetime-best-practice/ [
check this out:
http://blog.sqlauthority.com/2007/06/10/sql-server-retrieve-select-only-date-part-from-datetime-best-practice/[^]
hope it helps :)
有多种方法可以做到这一点,其中一种方法
SELECT CONVERT(VARCHAR(10),GETDATE(),103)
103用于格式dd/mm/yyyy
There are different ways to do this, one of the ways
SELECT CONVERT(VARCHAR(10),GETDATE(),103)
103 is for format dd/mm/yyyy
试试这个.
Hi,
Try this.
SELECT CAST(GETDATE() AS DATE)
这样,您只会得到日期:)
问候,
爱德华
With that, you will get the date only :)
Regards,
Eduard
这篇关于如何在没有时间的情况下独自获得约会部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文