sql - Oracle date datatype vs sysdate -
in table sales there expiry date field of date type. now, have write query selects records having expiry date greater current system date.
select * sales expiry_date > sysdate; in output getting all records expiry date 31/12/9999 00:00:00, not desired.
" in output getting records expiry date 31/12/9999 00:00:00 not desired."
but that's query asks for: must admit year 9999 greater current year.
so either query correct , have misunderstood requirement, or need re-write query explicitly exclude records maximum date.
presumably in case expiry_date defined not null , late change when raised matter of records never expire. instead have magic value of 31-12-9999 ,which means of "these records not expire".
anyhow, here query now:
select * sales expiry_date > sysdate , expiry_date != date '9999-12-31'; this common problem magic values: offer quick fix architectural problem levy ongoing tax on application logic.
Comments
Post a Comment