DateTime query on only year in SQL Server

前端 未结 8 1626
灰色年华
灰色年华 2021-01-12 08:01

I want to select multiple records on the basis of a matching year, for example in table tab where columns are [id] int, [name] varchar, [boo

8条回答
  •  星月不相逢
    2021-01-12 08:20

    Yes, if you try this query:

    SELECT to_date ('2008','yyyy') AS my_date, SYSDATE FROM dual;
    

    The date will be the year (2008) and the current month (today is November), and the day is 1 so your query do not includes all months in 2008.

提交回复
热议问题