I want to get the data of two given dates(i.e from and to dates) in database I have those two fields and when the given dates are not falling in between the dates then it will throw an error Example :
Database has two rows of from and to dates 01-12-2020 to 10-12-2020 11-12-2020 to 20-12-2020 Given from and to dates are 15-12-2020 to 31-12-2020
It is throwing an error but when I gave 02-12-2020 to 11-12-2020 it is accepting which should not be the case as those dates are not falling in between any of the the above given dates.
so far I tried like this..
if ((item.StartDate >= viewModel.PeriodFrom.Value && endDate <= viewModel.PeriodTo.Value) || (item.StartDate <= viewModel.PeriodFrom.Value && endDate >= viewModel.PeriodTo.Value)){
results = true;
ClientRef = item.Client_Ref;
TempData["Clienttemp"] = ClientRef;
}
else {
Tempdata["msg"] = "dates are not available.";
Return false;
}
Here if the dates are available it returns true.
Aucun commentaire:
Enregistrer un commentaire