Comparing two equal timestamps with '>' operator returns true












0















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();









share|improve this question

























  • TimeStamp is the wrong terminology, DateTime is more clear, as they are technically completely different things, in C# and SQL server

    – Michael Randall
    Nov 22 '18 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 '18 at 4:31











  • When you ran a DB trace, what was the exact SQL being submitted to the database?

    – mjwills
    Nov 22 '18 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 '18 at 4:40








  • 2





    @AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.

    – Access Denied
    Nov 22 '18 at 4:41


















0















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();









share|improve this question

























  • TimeStamp is the wrong terminology, DateTime is more clear, as they are technically completely different things, in C# and SQL server

    – Michael Randall
    Nov 22 '18 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 '18 at 4:31











  • When you ran a DB trace, what was the exact SQL being submitted to the database?

    – mjwills
    Nov 22 '18 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 '18 at 4:40








  • 2





    @AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.

    – Access Denied
    Nov 22 '18 at 4:41
















0












0








0








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();









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 8:34









labilbe

2,66822031




2,66822031










asked Nov 22 '18 at 4:25









Amit UpadhyayAmit Upadhyay

3,35632744




3,35632744













  • TimeStamp is the wrong terminology, DateTime is more clear, as they are technically completely different things, in C# and SQL server

    – Michael Randall
    Nov 22 '18 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 '18 at 4:31











  • When you ran a DB trace, what was the exact SQL being submitted to the database?

    – mjwills
    Nov 22 '18 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 '18 at 4:40








  • 2





    @AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.

    – Access Denied
    Nov 22 '18 at 4:41





















  • TimeStamp is the wrong terminology, DateTime is more clear, as they are technically completely different things, in C# and SQL server

    – Michael Randall
    Nov 22 '18 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 '18 at 4:31











  • When you ran a DB trace, what was the exact SQL being submitted to the database?

    – mjwills
    Nov 22 '18 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 '18 at 4:40








  • 2





    @AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.

    – Access Denied
    Nov 22 '18 at 4:41



















TimeStamp is the wrong terminology, DateTime is more clear, as they are technically completely different things, in C# and SQL server

– Michael Randall
Nov 22 '18 at 4:31





TimeStamp is the wrong terminology, DateTime is more clear, as they are technically completely different things, in C# and SQL server

– Michael Randall
Nov 22 '18 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 '18 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 '18 at 4:31













When you ran a DB trace, what was the exact SQL being submitted to the database?

– mjwills
Nov 22 '18 at 4:32





When you ran a DB trace, what was the exact SQL being submitted to the database?

– mjwills
Nov 22 '18 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 '18 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 '18 at 4:40






2




2





@AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.

– Access Denied
Nov 22 '18 at 4:41







@AmitUpadhyay mjwills wanted you to look at sql command submitted to sql server.

– Access Denied
Nov 22 '18 at 4:41














0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?