SQL Server datetime comparison in different formats

前端 未结 2 1453
礼貌的吻别
礼貌的吻别 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.

    0 讨论(0)
  • 2021-01-17 02:47

    Refer to the DateTime Formating for this purpose, by providing certain parameters we can format the date into required format.

    0 讨论(0)
提交回复
热议问题