select * from myTable where timestamp > 16xxxxxxxx;
Hm, I have never seen a number "16xxxxxxxx", it just looks strange to
me, even to a German (who swaps "."s and ","s in numbers ;-) )
I've found that this always returns true, even when it shouldn't. I can
(and have) fix(ed) it by doing:
select * from myTable where timestamp+0 > 16xxxxxxxx;
I gues this tries to fix it from the wrong side. It might work if
"timestamp" is a string, but not if "timestamp" is already a number.
Why do you think you MUST compare strings rather than numbers?
If the above doesn't help: what does your "CREATE TABLE" statement look
like?
Yes, it is off-topic, but... I am running this from a shell script, so...
Anyway, I'm hoping someone out there is a SQL expert - well, at least more knowledgeable than I am (which is a pretty low bar).
I have a table, with a field that contains timestamps (usual Unix epoch number, which these days is a 10 digit number starting with "16"). I want
to compare it to another, fixed, value (which happens to be the current
time, generated by another script (not written in SQL)). So, I do:
select * from myTable where timestamp > 16xxxxxxxx;
I've found that this always returns true, even when it shouldn't. I can
(and have) fix(ed) it by doing:
select * from myTable where timestamp+0 > 16xxxxxxxx;
which I kind of "random walked" myself into. But I am curious if there is
a better way to solve this. The above, although kind of standard in AWK
(and note that SQL seems to share a lot of ideological similarity with AWK), still looks like a kludge.
Notes:
1) I didn't do anything special in the "CREATE TABLE" command for this
field. I think there is a way to declare it numeric, but I don't
understand that very well.
2) This is *NOT* an incarnation of the usual "comparing numbers as
strings" problem (where, e.g., 2 sorts above 10), since the things
being compared here are known to be all the same length. So, a
string comparison should work OK.
In article <io16f9Fo6p1U1@mid.individual.net>,
Josef Moellers <josef.moellers@invalid.invalid> wrote:
...
select * from myTable where timestamp > 16xxxxxxxx;
Hm, I have never seen a number "16xxxxxxxx", it just looks strange to
me, even to a German (who swaps "."s and ","s in numbers ;-) )
I am using an actual number (an integer, though, not a "real number" - yes,
I am kidding...). The Xs were just standins.
I've found that this always returns true, even when it shouldn't. I can >>> (and have) fix(ed) it by doing:
select * from myTable where timestamp+0 > 16xxxxxxxx;
I gues this tries to fix it from the wrong side. It might work if
"timestamp" is a string, but not if "timestamp" is already a number.
Note sure what you mean by this.
Why do you think you MUST compare strings rather than numbers?
I don't. The point is I want them to compare as numbers. Hence the +0.
I'm just pointing out that it "should" work even if they were being compared as strings.
If the above doesn't help: what does your "CREATE TABLE" statement look
like?
Just: CREATE TABLE xxx foo,bar,timestamp;
Anyway, thanx for response. Hope to see more from you.
Just: CREATE TABLE xxx foo,bar,timestamp;
Anyway, thanx for response. Hope to see more from you.
Yes, it is off-topic, but... I am running this from a shell script, so...
Anyway, I'm hoping someone out there is a SQL expert - well, at least more knowledgeable than I am (which is a pretty low bar).
I have a table, with a field that contains timestamps (usual Unix epoch number, which these days is a 10 digit number starting with "16"). I want
to compare it to another, fixed, value (which happens to be the current
time, generated by another script (not written in SQL)). So, I do:
select * from myTable where timestamp > 16xxxxxxxx;
I've found that this always returns true, even when it shouldn't. I can
(and have) fix(ed) it by doing:
select * from myTable where timestamp+0 > 16xxxxxxxx;
which I kind of "random walked" myself into. But I am curious if there is
a better way to solve this. The above, although kind of standard in AWK
(and note that SQL seems to share a lot of ideological similarity with AWK), still looks like a kludge.
Notes:
1) I didn't do anything special in the "CREATE TABLE" command for this
field. I think there is a way to declare it numeric, but I don't
understand that very well.
2) This is *NOT* an incarnation of the usual "comparing numbers as
strings" problem (where, e.g., 2 sorts above 10), since the things
being compared here are known to be all the same length. So, a
string comparison should work OK.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 292 |
Nodes: | 16 (2 / 14) |
Uptime: | 209:24:45 |
Calls: | 6,618 |
Files: | 12,168 |
Messages: | 5,317,175 |