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 > Informix > date manipulation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-21-08, 21:22
norani norani is offline
Registered User
 
Join Date: Oct 2008
Posts: 4
date manipulation

i'm preparing a stored procedure to manipulate a date datatype. Can somebody help me on how to list out all dates between 2 given dates. For example input 1 is '03/05/2008' and input 2 is '03/08/2008'.

I need the result to be :

'03/05/2008'
'03/06/2008'
'03/07/2008'
'03/08/2008'

Pls help.
Reply With Quote
  #2 (permalink)  
Old 10-23-08, 04:45
stanislav.ondac stanislav.ondac is offline
Registered User
 
Join Date: Aug 2005
Posts: 140
Code:
create function datumy (dat1 date,dat2 date)
returning set(date not null);
define diff integer;
define i integer;
define datmn set(date not null);
let diff=dat2-dat1;
let diff=diff -1;
for i in (1 to diff step 1)
insert into table(datmn) values(dat1+i);
end for

return datmn;
end function;

hope this helps
Reply With Quote
  #3 (permalink)  
Old 10-24-08, 00:08
norani norani is offline
Registered User
 
Join Date: Oct 2008
Posts: 4
date manipulation

Thank you.

But instead of inserting the result into a table can I list the result straight away. This is because I need to execute the procedure/function in the client application, I don't want to call another table to get the result.

Thanks.
Reply With Quote
  #4 (permalink)  
Old 10-24-08, 04:38
stanislav.ondac stanislav.ondac is offline
Registered User
 
Join Date: Aug 2005
Posts: 140
AFAIK this is not possible with SPL. It actually doesn't fall into philosophy of stored procedures.
Reply With Quote
  #5 (permalink)  
Old 10-24-08, 05:02
norani norani is offline
Registered User
 
Join Date: Oct 2008
Posts: 4
ok, thank you. i will work out on this.
Reply With Quote
  #6 (permalink)  
Old 10-28-08, 06:34
Mokbol Mokbol is offline
Registered User
 
Join Date: Oct 2008
Posts: 3
stored procedure

stored procedure to manipulate a date datatype. Can somebody help me on how to list out all dates between 2 given dates. For example input 1 is '03/05/2008' and input 2 is '03/08/2008
Reply With Quote
  #7 (permalink)  
Old 10-30-08, 22:24
Patrick Kong Patrick Kong is offline
Registered User
 
Join Date: Jul 2008
Posts: 8
Maybe something like this,
add code to validate from_date >= to_date;

create procedure blah (
from_date date,
to_date date)
returning date;

define return_date date;

let return_date = from_date;

while (return_date <= to_date)

return return_date;

let return_date = return_date + 1 units day;

end while;

end procedure;

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