Skip to content

Instantly share code, notes, and snippets.

@kyawzaymoore
Last active October 1, 2021 09:35
Show Gist options
  • Save kyawzaymoore/1a432da2fb715675061ec0b4dc15302f to your computer and use it in GitHub Desktop.
Save kyawzaymoore/1a432da2fb715675061ec0b4dc15302f to your computer and use it in GitHub Desktop.
Linq Between two dates
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
DateTime assignDateStart = DateTime.Now.AddDays(5).Date;
DateTime assignDateEnd = DateTime.Now.AddDays(6).Date;
DateTime startDate = DateTime.Now.AddDays(3).Date;
DateTime endDate = DateTime.Now.AddDays(8).Date;
if((startDate <= assignDateStart && assignDateStart <= endDate) || (startDate <= assignDateEnd && assignDateEnd <= endDate))
{
Console.WriteLine("True ---> " + startDate.ToString("dd MMM") + " <= " + assignDateStart.ToString("dd MMM") + " - " + assignDateEnd.ToString("dd MMM") + " <= " + endDate.ToString("dd MMM"));
}
else
{
Console.WriteLine("False ---> " + startDate.ToString("dd MMM") + " <= " + assignDateStart.ToString("dd MMM") + " - " + assignDateEnd.ToString("dd MMM") + " <= " + endDate.ToString("dd MMM"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment