Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@janosorcsik
Last active November 20, 2020 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janosorcsik/e1bb1ca7c705d047787288a6cdd5ad85 to your computer and use it in GitHub Desktop.
Save janosorcsik/e1bb1ca7c705d047787288a6cdd5ad85 to your computer and use it in GitHub Desktop.
DateTime collision check

Not nullable overlap

(x.StartDate <= y.EndDate && x.EndDate >= y.StartDate)

Nullable overlap

(x.StartDate ?? y.EndDate <= y.EndDate ?? x.StartDate) && (x.EndDate ?? y.StartDate >= y.StartDate ?? x.EndDate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment