Created
July 12, 2024 07:37
-
-
Save r1d3rzz/d25bedb5d5f3b67d4d4661ad384a8750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assuming employee.PermanentEndDate is DateTime? (nullable DateTime) | |
if (employee.PermanentEndDate.HasValue) | |
{ | |
var empPermanentEndDate = employee.PermanentEndDate.Value.Date; // Use .Date to ignore the time part | |
var today = DateTime.Today; | |
var previousDay = DateTime.Today.AddDays(-1); | |
if (empPermanentEndDate == previousDay && previousDay == today) | |
{ | |
// Do something if empPermanentEndDate is the same as yesterday and today | |
} | |
else if (empPermanentEndDate == previousDay) | |
{ | |
// Do something if empPermanentEndDate is the same as yesterday but not today | |
} | |
else if (empPermanentEndDate == today) | |
{ | |
// Do something if empPermanentEndDate is the same as today but not yesterday | |
} | |
else | |
{ | |
// Do something if empPermanentEndDate is neither today nor yesterday | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment