DateTime.Now converting

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Juflet
Posts: 1
Joined: Thu 03 Mar 2016 12:42

DateTime.Now converting

Post by Juflet » Thu 03 Mar 2016 12:59

Hi!
I have a problem with DateTime type. Api Server and DB are on different servers. So we have some problem with sync time. When i used DateTime.UtcNow, PostgeSQL takes query with "CURRENT_TIMESTAMP AT TIME ZONE 'UTC')", but needed send requests from API server by datetime value of the DateTime.UtcNow. Is there any way to build query with value.
P.S. Sorry for my english.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: DateTime.Now converting

Post by Shalex » Fri 04 Mar 2016 11:56

Please use

Code: Select all

var a = DateTime.UtcNow;
[...].GetAll(true).Where(x => x.CreatedDate < a).OrderByDescending(x => x.CreatedDate)[...]
// converted to WHERE ("Extent1".createddate < :p__linq__0)
instead of

Code: Select all

[...].GetAll(true).Where(x => x.CreatedDate < DateTime.UtcNow).OrderByDescending(x => x.CreatedDate)[...]
// converted to WHERE ("Extent1".createddate < (CURRENT_TIMESTAMP AT TIME ZONE 'UTC'))

Post Reply