I am pulling a date value from my database:
Dim qfresho = From p In dbConfig.Configs _
Where p.Description = "FROD" _
Select p.dateValue
Dim qfreshc = From p In dbConfig.Configs _
Where p.Description = "FRCD" _
Select p.dateValue
Then comparing these date values to the current date:
If qfresho.First.Value >= Date.Now And qfreshc.First.Value <= Date.Now Then
lblFreshman.Text = "Freshmen are currently eligible to register for a room."
Else
Dim frdays As TimeSpan
frdays = (qfresho.First.Value).Subtract(Now)
lblFreshman.Text = "Registration will open for freshmen in " & frdays.Days & " days."
End If
But for some reason its always returning the Else condition – even though the values in the database should make the query true. Any ideas? I’m guessing for some reason its not pulling the results as a date?
Date.Now returns a DateTime, so does your database have dates and times or just dates? If you just want the date, you can use Date.Today.