Comparing two equal timestamps with '>' operator returns true
up vote
0
down vote
favorite
I am writing a query in OrmLite like:
var items = db.Select<CustomTable>(query => query
.Where(record => record.UpdateTimestamp > lastUpdateTime)
.OrderBy(status => status.UpdateTimestamp)
.Limit(limit));
return items;
This expression record.UpdateTimestamp > lastUpdateTime
in the above query is returning true but the values of both of them are exactly the same in the database. Also on debugging the program, I find they store the exact same value which is: 2018-11-19 11:35:05.24345
.
On further debugging, I found that the above query is working fine for timestamp which has the precision of time up to the 3rd decimal place. Eg:
Comparing 2018-11-19 11:35:05.123
and 2018-11-19 11:35:05.123
with >
operator like in the above query returns false, but when I do increase the precision up to the 4th decimal place, then it starts failing.
Also, The UpdateTimestamp in CustomTable and lastUpdateTime
both are a DateTime
object only.
What could be the proper solution for this?
UPDATE
I am getting the value of lastUpdateTime
from the db, with the query like:
db.Select<SomeTable>(query => query.Where(row => "SomeKey" == key)).FirstOrDefault();
c# postgresql timestamp ormlite-servicestack
|
show 6 more comments
up vote
0
down vote
favorite
I am writing a query in OrmLite like:
var items = db.Select<CustomTable>(query => query
.Where(record => record.UpdateTimestamp > lastUpdateTime)
.OrderBy(status => status.UpdateTimestamp)
.Limit(limit));
return items;
This expression record.UpdateTimestamp > lastUpdateTime
in the above query is returning true but the values of both of them are exactly the same in the database. Also on debugging the program, I find they store the exact same value which is: 2018-11-19 11:35:05.24345
.
On further debugging, I found that the above query is working fine for timestamp which has the precision of time up to the 3rd decimal place. Eg:
Comparing 2018-11-19 11:35:05.123
and 2018-11-19 11:35:05.123
with >
operator like in the above query returns false, but when I do increase the precision up to the 4th decimal place, then it starts failing.
Also, The UpdateTimestamp in CustomTable and lastUpdateTime
both are a DateTime
object only.
What could be the proper solution for this?
UPDATE
I am getting the value of lastUpdateTime
from the db, with the query like:
db.Select<SomeTable>(query => query.Where(row => "SomeKey" == key)).FirstOrDefault();
c# postgresql timestamp ormlite-servicestack
TimeStamp
is the wrong terminology,DateTime
is more clear, as they are technically completely different things, in C# and SQL server
– TheGeneral
Nov 22 at 4:31
It would be awesome if you could provide a Minimal, Complete, and Verifiable example including howlastUpdateTime
is populated.
– mjwills
Nov 22 at 4:31
When you ran a DB trace, what was the exact SQL being submitted to the database?
– mjwills
Nov 22 at 4:32
This one returns falsestring s = "2018.11.19 11:35:05.24345"; DateTime d = DateTime.Parse(s,CultureInfo.InvariantCulture); DateTime d2 = DateTime.Parse(s, CultureInfo.InvariantCulture); bool res=d>d2;
– Access Denied
Nov 22 at 4:40
2
@AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.
– Access Denied
Nov 22 at 4:41
|
show 6 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am writing a query in OrmLite like:
var items = db.Select<CustomTable>(query => query
.Where(record => record.UpdateTimestamp > lastUpdateTime)
.OrderBy(status => status.UpdateTimestamp)
.Limit(limit));
return items;
This expression record.UpdateTimestamp > lastUpdateTime
in the above query is returning true but the values of both of them are exactly the same in the database. Also on debugging the program, I find they store the exact same value which is: 2018-11-19 11:35:05.24345
.
On further debugging, I found that the above query is working fine for timestamp which has the precision of time up to the 3rd decimal place. Eg:
Comparing 2018-11-19 11:35:05.123
and 2018-11-19 11:35:05.123
with >
operator like in the above query returns false, but when I do increase the precision up to the 4th decimal place, then it starts failing.
Also, The UpdateTimestamp in CustomTable and lastUpdateTime
both are a DateTime
object only.
What could be the proper solution for this?
UPDATE
I am getting the value of lastUpdateTime
from the db, with the query like:
db.Select<SomeTable>(query => query.Where(row => "SomeKey" == key)).FirstOrDefault();
c# postgresql timestamp ormlite-servicestack
I am writing a query in OrmLite like:
var items = db.Select<CustomTable>(query => query
.Where(record => record.UpdateTimestamp > lastUpdateTime)
.OrderBy(status => status.UpdateTimestamp)
.Limit(limit));
return items;
This expression record.UpdateTimestamp > lastUpdateTime
in the above query is returning true but the values of both of them are exactly the same in the database. Also on debugging the program, I find they store the exact same value which is: 2018-11-19 11:35:05.24345
.
On further debugging, I found that the above query is working fine for timestamp which has the precision of time up to the 3rd decimal place. Eg:
Comparing 2018-11-19 11:35:05.123
and 2018-11-19 11:35:05.123
with >
operator like in the above query returns false, but when I do increase the precision up to the 4th decimal place, then it starts failing.
Also, The UpdateTimestamp in CustomTable and lastUpdateTime
both are a DateTime
object only.
What could be the proper solution for this?
UPDATE
I am getting the value of lastUpdateTime
from the db, with the query like:
db.Select<SomeTable>(query => query.Where(row => "SomeKey" == key)).FirstOrDefault();
c# postgresql timestamp ormlite-servicestack
c# postgresql timestamp ormlite-servicestack
edited Nov 23 at 8:34
labilbe
2,58821931
2,58821931
asked Nov 22 at 4:25
Amit Upadhyay
2,92322542
2,92322542
TimeStamp
is the wrong terminology,DateTime
is more clear, as they are technically completely different things, in C# and SQL server
– TheGeneral
Nov 22 at 4:31
It would be awesome if you could provide a Minimal, Complete, and Verifiable example including howlastUpdateTime
is populated.
– mjwills
Nov 22 at 4:31
When you ran a DB trace, what was the exact SQL being submitted to the database?
– mjwills
Nov 22 at 4:32
This one returns falsestring s = "2018.11.19 11:35:05.24345"; DateTime d = DateTime.Parse(s,CultureInfo.InvariantCulture); DateTime d2 = DateTime.Parse(s, CultureInfo.InvariantCulture); bool res=d>d2;
– Access Denied
Nov 22 at 4:40
2
@AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.
– Access Denied
Nov 22 at 4:41
|
show 6 more comments
TimeStamp
is the wrong terminology,DateTime
is more clear, as they are technically completely different things, in C# and SQL server
– TheGeneral
Nov 22 at 4:31
It would be awesome if you could provide a Minimal, Complete, and Verifiable example including howlastUpdateTime
is populated.
– mjwills
Nov 22 at 4:31
When you ran a DB trace, what was the exact SQL being submitted to the database?
– mjwills
Nov 22 at 4:32
This one returns falsestring s = "2018.11.19 11:35:05.24345"; DateTime d = DateTime.Parse(s,CultureInfo.InvariantCulture); DateTime d2 = DateTime.Parse(s, CultureInfo.InvariantCulture); bool res=d>d2;
– Access Denied
Nov 22 at 4:40
2
@AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.
– Access Denied
Nov 22 at 4:41
TimeStamp
is the wrong terminology, DateTime
is more clear, as they are technically completely different things, in C# and SQL server– TheGeneral
Nov 22 at 4:31
TimeStamp
is the wrong terminology, DateTime
is more clear, as they are technically completely different things, in C# and SQL server– TheGeneral
Nov 22 at 4:31
It would be awesome if you could provide a Minimal, Complete, and Verifiable example including how
lastUpdateTime
is populated.– mjwills
Nov 22 at 4:31
It would be awesome if you could provide a Minimal, Complete, and Verifiable example including how
lastUpdateTime
is populated.– mjwills
Nov 22 at 4:31
When you ran a DB trace, what was the exact SQL being submitted to the database?
– mjwills
Nov 22 at 4:32
When you ran a DB trace, what was the exact SQL being submitted to the database?
– mjwills
Nov 22 at 4:32
This one returns false
string s = "2018.11.19 11:35:05.24345"; DateTime d = DateTime.Parse(s,CultureInfo.InvariantCulture); DateTime d2 = DateTime.Parse(s, CultureInfo.InvariantCulture); bool res=d>d2;
– Access Denied
Nov 22 at 4:40
This one returns false
string s = "2018.11.19 11:35:05.24345"; DateTime d = DateTime.Parse(s,CultureInfo.InvariantCulture); DateTime d2 = DateTime.Parse(s, CultureInfo.InvariantCulture); bool res=d>d2;
– Access Denied
Nov 22 at 4:40
2
2
@AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.
– Access Denied
Nov 22 at 4:41
@AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.
– Access Denied
Nov 22 at 4:41
|
show 6 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423876%2fcomparing-two-equal-timestamps-with-operator-returns-true%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
TimeStamp
is the wrong terminology,DateTime
is more clear, as they are technically completely different things, in C# and SQL server– TheGeneral
Nov 22 at 4:31
It would be awesome if you could provide a Minimal, Complete, and Verifiable example including how
lastUpdateTime
is populated.– mjwills
Nov 22 at 4:31
When you ran a DB trace, what was the exact SQL being submitted to the database?
– mjwills
Nov 22 at 4:32
This one returns false
string s = "2018.11.19 11:35:05.24345"; DateTime d = DateTime.Parse(s,CultureInfo.InvariantCulture); DateTime d2 = DateTime.Parse(s, CultureInfo.InvariantCulture); bool res=d>d2;
– Access Denied
Nov 22 at 4:40
2
@AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.
– Access Denied
Nov 22 at 4:41