A
A
Alex4930494692018-02-21 07:24:46
C++ / C#
Alex493049469, 2018-02-21 07:24:46

Problem with DATETIME?

The problem is that in the database the date and time data is stored in DATETIME utc.
Initially entered in a different time zone.
There is a problem when you need to pull out data for the month:
In utc, for example, this is 01/31/2018, and in local it is already 02/01/2018.
So how do I get the correct monthly data without wasting a day?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2018-02-21
@klim76

where dateadd(H,3,[yourdata inUTC]) > '2018-02-01'

B
basrach, 2018-02-21
@basrach

When EF gets the data, you can tell it to read the dates in UTC.
Look here and here .
Well, then either new DateTime(02/01/2018).ToUniversalTime(), or new DateTime(01/31/2018, DateTimeKind.Utc)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question