Thursday, March 29, 2012

date question

in my database i stored information on what time the purchaed were made something like this...

ItemNo|dateofPurchased
*********************
0001 | 12/08/2003
0002 | 1/24/2002
0003 | 5/18/2001

......

if i wish to get the itemno that were purchased before year 2002 how do i do it by sql statements?
thanks...Originally posted by HjF_84
in my database i stored information on what time the purchaed were made something like this...

ItemNo|dateofPurchased
*********************
0001 | 12/08/2003
0002 | 1/24/2002
0003 | 5/18/2001

......

if i wish to get the itemno that were purchased before year 2002 how do i do it by sql statements?
thanks...
The answer depends on your DBMS. For Oracle you would say:

select itemno
from xxx
where dateofpurchased < TO_DATE('01-JAN-2002','DD-MON-YYYY');

But TO_DATE is Oracle-specific.|||i using sql server2000..., so anyone know how to retreive it...?

No comments:

Post a Comment