Hope your well and can help me with a little problem i am encountering.
The query below compares the closed data in legacy vs closed date in current. What i have noticed is if the closed date is blank in both legacy and current then the ClosedMatch = False.
The ideal outcome would be ClosedMatch = True ( as both Columns are the same).
What else do i need to add to my statement below to get the correct outcome ?
Select
LEGACY.DATE_CLOSED__C as LClosedDate,
CURRENT.DATE_CLOSED__C as ClosedDate,
Case when CURRENT.DATE_CLOSED__C = LEGACY.DATE_CLOSED__C Then 'True' ELSE 'False' END AS ClosedMatch
From LEGACY
Inner join CURRENT
On LEGACY.ACCOUNT_CODE__C=CURRENT.Account_Code__c
What you see as blanks may be NULLs. Try the following:
SELECT
LEGACY.DATE_CLOSED__C AS LClosedDate,
CURRENT.DATE_CLOSED__C AS ClosedDate,
CASE
WHEN COALESCE(CURRENT.DATE_CLOSED__C,'19000101') = COALESCE(LEGACY.DATE_CLOSED__C,'19000101') THEN 'True'
ELSE 'False'
END AS ClosedMatch
FROM
LEGACY
INNER JOIN [CURRENT]
ON LEGACY.ACCOUNT_CODE__C=CURRENT.Account_Code__c
You might have to tweak the query based on whether you have 1/1/1900 in any of the actual data.
@harishgg1 i updated all the tables to a consist data type. which hopefully makes my life a little similar going forward. Thank you all for your inputs