I have the following table:
ID ActualDt DueDt Flag
-- ------- ------- ----
1 01/03/12 09/13/12 Y
2 NULL 07/12/12 Y
3 NULL 09/12/12 N
4 02/03/12 01/13/12 N
I need to mark Flag as Y for the following conditions:
1) If ActualDt is not null and DueDt is not null and DueDt > ActualDt
2) If ActualDt is null and DueDt is past due based on current date
Otherwise, Flag = N
Note that ActualDt is a string
How would I program this in t-sql
I know I need a case statement.
You need an update statement:
This query assumes that the format of the date matches the default format for the database. My database is set to US standards, so ’01/03/12′ is interpreted as Jan 3, 2012.