-1
where (au.[DateTime]>= DATEADD(WK,-12,GETDATE()) AND au.[DateTime]< GETDATE())    
--gets everyday for the last 12 weeks

How can I modify to get every day for YTD?

FutbolFan
  • 13,235
  • 3
  • 23
  • 35
Si8
  • 9,141
  • 22
  • 109
  • 221

1 Answers1

1
where au.[DateTime] between DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)
 AND DATEADD(ms,-2,DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0))

This will get you the first day of the current year. A point i am not sure you need the And au.datetime ... since it is YTD it cannot have tomorrow data yet ? I tried -1 MS but for some reason it doesn't work. possible question.

Holmes IV
  • 1,673
  • 2
  • 23
  • 47