I have a df
Begin_Date Last_date
2010-03-30 NULL
2010-04-07 2010-07-10
I want to calculate a column effective last date such that if there is null in last_date column, then I should get today's date (NULL in last_date column means the last date is not yet reached, still active)
Begin_Date Last_date Effective_date
2010-03-30 NULL 2020-09-08 #Today's date
2010-04-07 2010-07-10 2010-07-10
Code:
ALTER TABLE df ADD Effective_date AS
COALESCE(Last_date, GETDATE()) ;
Output I am getting:
Begin_Date Last_date Effective_date
2010-03-30 NULL 2020-09-08 00:00:00:000 Today's date
2010-04-07 2010-07-10 2010-07-10
How to remove the 00:00:00:000 part from date?