If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > date question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-05-03, 02:20
HjF_84 HjF_84 is offline
Registered User
 
Join Date: Sep 2003
Posts: 2
Question 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....
Reply With Quote
  #2 (permalink)  
Old 09-05-03, 06:13
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: date question

Quote:
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.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 09-08-03, 23:10
HjF_84 HjF_84 is offline
Registered User
 
Join Date: Sep 2003
Posts: 2
i using sql server2000..., so anyone know how to retreive it...?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On