4thSpace
4thSpace

Reputation: 44332

Matching sql date with .NET date

Should the following always match:

if(mydbrecord.DateField.Date == DateTime.Now.Date)
{...}

where mydbrecord date is the current day? I'm retrieving mydbrecord through linq-sql.

mydbrecord.DateField.Date is in the format '2013-12-19 00:00:00.000'.

Upvotes: 0

Views: 40

Answers (1)

Jade
Jade

Reputation: 2992

Do it like this

if(mydbrecord.DateField.Date.ToString("yyyy/MM/dd") == DateTime.Now.Date.ToString("yyyy/MM/dd"))
{...}

Upvotes: 1

Related Questions