简体   繁体   中英

What is the easiest way to validate date duration from two DateTimePicker in C#.net?

So I have this program for assigning people to projects. In my database I already have some samples projects with assigned employees. I have to be able to cross match my current project's start and end date to the projects that the employee is assigned too.

I can't do it like

if (this_StartDate == assignedProj_StartDate || this_EndDate == assignedProj_EndDate)

because that would only match the exact dates.

I need to be able to mark the employee available if this_StartDate & this_EndDate is not within the period of the assigned project to him. Help?

It sounds like you want to check whether the the this range is outside of the assignedProj range:

if (this_StartDate > assignedProj_EndDate 
 || this_EndDate < assignedProj_StartDate)

This assumes that both ranges are valid (end > start)

>和<符号可能对您有用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM