如何在没有时间的情况下独自获得约会部分

问题描述:

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