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 > Database Server Software > DB2 > selecting datasets which are updatet within the last x weeks! how?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-24-03, 04:49
scoobee scoobee is offline
Registered User
 
Join Date: Nov 2003
Posts: 1
selecting datasets which are updatet within the last x weeks! how?

Hello,

I've got a question.

How is it possible to select datasets which are updateted within the last x weeks.

it has to look something like this i think:

select * from data WHERE date >= current_Timestamp - x weeks;

, but i dont know how to fit in the weeks into that statement. my date is saved as a timestamp in my database ("20031119113909").

i would be very happy if someone might help me.

thanks a lot

sorry for my english, its not the best i think
Reply With Quote
  #2 (permalink)  
Old 11-24-03, 07:58
RKrick RKrick is offline
Registered User
 
Join Date: Feb 2002
Location: Germany
Posts: 141
Re: selecting datasets which are updatet within the last x weeks! how?

Scoobee,

if you don't need the actual week, you can just use 7 days.
For example, for 2 weeks you'll use:
select * from data WHERE date >= current_Timestamp - (2 * 7) days;

If you really need the correct week, I would write a UDF using a combination of DAYOFWEEK(), WEEK() and so on.

HTH,
__________________
Rodney Krick
Reply With Quote
  #3 (permalink)  
Old 11-24-03, 13:08
M_RAS M_RAS is offline
Registered User
 
Join Date: Sep 2003
Location: canada
Posts: 230
Re: selecting datasets which are updatet within the last x weeks! how?

Quote:
Originally posted by RKrick
Scoobee,

if you don't need the actual week, you can just use 7 days.
For example, for 2 weeks you'll use:
select * from data WHERE date >= current_Timestamp - (2 * 7) days;

If you really need the correct week, I would write a UDF using a combination of DAYOFWEEK(), WEEK() and so on.

HTH,
Hi Rkrick,
I am working with db2V7.2 fixpack 6 AIX 5.2

could you please tell me (detail) how can create UDF? I know the coding of creating UDF but I have problem with how can compile it and how can create the modul in ..../sllib/function.
Thank you in advance for your help.
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