Q:

Compare two dates with a range

is it possible to have something that can compare two dates in this format..
example today "Sep 30, 2013" and one week ago "Sep 22, 2013"
if its within this range say "good" if older then say "not good"
how can I make this in C# or vb.net

A:

If difference between dates is smaller than 7 days, it will print "good" otherwise "Not good"
var ok = (firstDate-secondDate).TotalDays < 7? "good": "Not good";
Console.WriteLine(ok);

TotalDays is double so you can check if differnce is in full days, use Days if you want completed days difference as int
Read more about TimeSpan and it's properties.

A:

thanks to all users who helped me here.. this is the final code that I am using..
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Dim fileDate As Date = Convert.ToDateTime("Sep 25, 2013")
    Dim rightNow As Date = Convert.ToDateTime(Date.Now.ToString("MMM dd, yyyy"))
    Dim lastWeek = rightNow.AddDays(-7)

    If rightNow >= fileDate And lastWeek <= fileDate Then

        Debug.Print("its new")
    Else
        Debug.Print("too old")
    End If
End Sub

