I'm trying to do this:
--If the Day parameter is the current day, then set @EndDate to be yesterday instead.
--If the Day parameter is in the future, set @EndDate to yesterday.
I've tried a few different approaches including two down below. I'm fairly new to programming so odds are I'm missing something fairly simple. Basically, I am trying to set @EndDate conditionally, depending on what @Day is set to be.
Declare @Day datetime
Set @Day = '09/2/17 12:50'
SET @Day = DATEADD(dd, DATEDIFF(dd, 0, @Day), 0)
Declare @Enddate Datetime
Set @Enddate = Case @Day
When @Day < GETDATE() Then GETDATE() - 1
End
--Set @Enddate = @Day
--Where @Day < GETDATE()
--Set @Enddate = GETDATE()-1
--Where @Day >= GETDATE()
,Thanks
Aucun commentaire:
Enregistrer un commentaire