sql server - Case With Datepart For Weekday -
any ideas wrong following code?
i trying write case statement returns today's date on monday else takes max date table if today's date inst monday
thanks
select case [effectivedate] when datepart(weekday,getdate()) = 1 cast(getdate() date) else max ([effectivedate]) end, [arcdal01pr].[arctimeseries].[arc_ts_data].[pricecurvedata] [curvename] = 'g_h_ttf.eur'
select case [effectivedate] when datepart(weekday,getdate()) = 2 cast(getdate() date) else max ([effectivedate]) end, [arcdal01pr].[arctimeseries].[arc_ts_data].[pricecurvedata] [curvename] = 'g_h_ttf.eur
monday should 2nd day of week. u can try if using sql server 2012
select case [effectivedate] when weekday(getdate(),2) = 1 cast(getdate() date) else max ([effectivedate]) end, [arcdal01pr].[arctimeseries].[arc_ts_data].[pricecurvedata] [curvename] = 'g_h_ttf.eur
update
select case when datepart(weekday,getdate()) = 2 cast(getdate() date) else max ([effectivedate]) end [effectivedate] [arcdal01pr].[arctimeseries].[arc_ts_data].[pricecurvedata] [curvename] = 'g_h_ttf.eur'
Comments
Post a Comment