SQL Server datetime comparison in different formats

前端 未结 2 1485
礼貌的吻别
礼貌的吻别 2021-01-17 02:24

I have a SQL query in which I will be passing dd/mm/yyyy but the SQL query requires mm/dd/yyyy.

How can I enable this query to take d

2条回答
  •  醉话见心
    2021-01-17 02:36

    For the query I would use dates in YYYY-MM-DD format. As to the output see kalyan's answer.

    EDIT: To summarise the comments below (thanks to marc_s) it is necessary to use the format YYYYMMDD when the time part is not included unless you are using the new date types date, datetime2 and datetimeoffset in SQL Server 2008.

提交回复
热议问题