Get a list of dates between two dates using a function

前端 未结 21 1102
天涯浪人
天涯浪人 2020-11-22 06:25

My question is similar to this MySQL question, but intended for SQL Server:

Is there a function or a query that will return a list of days between two dates? For exa

21条回答
  •  灰色年华
    2020-11-22 07:04

    Would all these dates be in the database already or do you just want to know the days between the two dates? If it's the first you could use the BETWEEN or <= >= to find the dates between

    EXAMPLE:

    SELECT column_name(s)
    FROM table_name
    WHERE column_name
    BETWEEN value1 AND value2
    

    OR

    SELECT column_name(s)
    FROM table_name
    WHERE column_name
    value1 >= column_name
    AND column_name =< value2
    

提交回复
热议问题