What will be the best script to get the records from a certain table with column createdDate and modifiedDate where modifiedDate is the only nullable column and is equal to date now/current date?
In case that there will be null values from modified date column, the script will get the created date.
The output should get all records with latest created or modified data. I tried these script below:
SELECT *
FROM table
WHERE ISNULL(CONVERT(date, ModifiedDate),
CONVERT(date,CreatedDate)) = CONVERT(date, getdate())
or
SELECT *
FROM table
WHERE CASE WHEN ModifiedDate IS NULL
THEN CONVERT(date, CreatedDate)
ELSE CONVERT(date,ModifiedDate) END = CONVERT(date, getdate())