problem
|
|
mssql - compare
two datetime
Mssql, compare two datetime fields, if their values are close, if are in 24h difference and do on --- > dennis |
|
difficulty level
|
|
1/10 :)))
|
|
compatibility
|
|
mssql
|
|
solution
|
|
In mssql, the
datetime fields are actually numeric with decimals. The integer part in the
“days”. So if you want to compare two dates compare the integer part as
bellow
-- compare if the item is sold 24h before the item is modified Select * from items Where ModificationDate<SaleDate-1 -- find person(s) that born on 12/11/2010 (not exactly on the same, with at least 12 hours difference) Select * from persons Where birthdate-0.5>=’2010-12-11’ and birthdate+0.5<=’2010-12-11’ |
Developing with CSharp many time you feel a strange feeling... then feeling of lost and how to solve it. Fortunately MSDN has done a good work to help the developers. .net offers thousand ways to do several things! This is the worst thing… because, you do not know where to start from and what works in real world! I hope to help you with your CSharpache.
Thursday, 24 November 2011
mssql - compare two datetime fields
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment