ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Having som trouble with some SQL in oracle.
Is it possible to retreive the date range of a specified week? So if I input week 10 I would get the dates within that week. Or just the start date.
It's easy to do the other way around (getting the week from a date).
CREATE OR REPLACE FUNCTION week_start ( week_num IN NUMBER)
return DATE
AS
value DATE :=NULL;
tmp_week NUMBER :=0;
tmp_year NUMBER :=0;
BEGIN
IF week_num < 1 OR week_num > 52
then
RETURN value;
END IF ;
SELECT -- find current year
TO_NUMBER(TO_CHAR(SYSDATE,'YYYY'))
INTO
tmp_year
FROM
dual;
value:='01-JAN-' || TO_CHAR(tmp_year,'9999');
WHILE tmp_week != week_num -- loop til we find week
LOOP
SELECT
TO_NUMBER( TO_CHAR(value, 'IW') )
INTO
tmp_week
FROM dual;
IF tmp_week != week_num
THEN
value:=value + 1;
END IF ;
END LOOP;
RETURN value;
END week_start;
/
-- example SQL call
select week_start(10) from dual;
create or replace
function getDateFromWeek(sYear_in in varchar2,sWeek_in in varchar2,iDay_in in number)return date
as
dRetDate date;
dCondate date;
nWeek pls_integer;
sWeek_one char(2);
begin
Hi there,
I need to add weeks in oracle. sysdate+(no_of_weeks*7) will not give correct result.
My requirement is like " need to get the same day after n weeks in oracle"
If today is MONDAY 28/11/2011 then after 6 weeks It should be MONDAY 09/01/2012...
select sysdate+(no_of_weeks*7) will create as issue when no of days in month is 31 or 28... please is there any function exist in oracle which will give " Same day date after n weeks".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.