I'm inserting customers the following way.
DateTime d = DateTime.Now;
foreach(Customer cus in CustomerList)
{
cus.EntryDate = d;
}
SaveToDatbase(CustomerList);
Date is getting saved successfully with the correct entry date, but however when I retrieve data back and compare it with variable d, it doesn't match.
foreach(Customer cus in GetFromDatabase())
{
Response.Write(DateTime.Compare(cus.EntryDate, d));
}
The output is 1 instead of 0. I checked the inserted data and it matches d variable value with milliseconds. Date is stored in sql server database. One thing I realized is if I reset milliseconds to 0 for cus.EntryDate and d, output is 0. What am I doing wrong here?