The following SQL statements are available:
Select CONVERT (varchar), DATEADD (Day,t2.number,t1.day), the day from (select ' 2015-07 ' + ' -01 ') t1, (select number From MASTER. Spt_values where type= ' P ' and number>=0 and number<=31) T2 where convert (varchar), DATEADD (day,t2.number,t1.day ) Like ' 2015-07% '
Note: To query a year, only 2015-07 of the statement can be replaced.
Results:
If you are querying for consecutive days in a certain period of time, you can write:
SELECT * FROM (
Select CONVERT (varchar), DATEADD (Day,t2.number,t1.day), the day from (select ' 2015-09 ' + ' -01 ') t1, (select number From MASTER. Spt_values where type= ' P ' and number>=0 and number<=31) T2 where convert (varchar), DATEADD (day,t2.number,t1.day ) Like ' 2015-09% '
) T
WHERE t.day > ' 2015-09-05 ' and T.day < ' 2015-09-15 '
As follows:
How to return one months of all days with SQL statement