0

I have a SQL Server 2008 table with to different dates: OrderDate and DeliveryDate. I'm using Entity Framework 6.

Both fields are datetime2(0) type.

Here is how I'm creating my object before saving it to database:

DateTime now = DateTime.Now;

order.OrderDate = now;
order.DeliveryDate = isScheduled ? scheduledDate : order.OrderDate;

When I save it to database the dates are different, for example:

  • OrderDate returns 2014-08-14 01:52:33
  • DeliveryDate returns 2014-08-14 01:52:31

Already tried changing datetime2 precision from 0 to 7 with no luck.

Any ideas please?

Yuliam Chandra
  • 14,494
  • 12
  • 52
  • 67
Daniel Kern
  • 41
  • 1
  • 4
  • 11
    Maybe `isScheduled` is `true` and it returns `scheduledDate` instead? Did you debug your code see their values? – Soner Gönül Aug 28 '14 at 07:55
  • Have you checked the table for triggers? – Johan Aug 28 '14 at 09:12
  • Thanks for the comments. @Johan There is no trigger in this table nor the whole database. @SonerGönül When `isScheduled` returns true it is expected dates are different. The problem happens when it returns false and it's supposed to be the exactly same datetime. – Daniel Kern Aug 28 '14 at 21:06
  • Anyone can help, please? This is driving me crazy. :D – Daniel Kern Aug 29 '14 at 21:25

0 Answers0