Week Number wrt Fisacal year
i want week no with respect to Fisical year (Apr2009-Mar2010) for Input date? Fisical year (Apr2009-Mar2010) keep changes from record to record. is there any standard function module or should i do any coding.
thanks
Raghu
Hi Raghu,
I am sorry I dint notice that you are not using a fiscal year variant. Fiscal year variants are specifically given for such puproses when you want to define your own year begins and ends unlike the calendar year.
Pls read thru this.
http://help.sap.com/saphelp_40b/helpdata/fr/95/e42c7dd435d1118b3f0060b03ca329/content.htm
I am sure this will be helpful.
Thanks
Mani
Similar Messages
-
Generating 52 weeks number of a year associated to a date
hi
I try to generate the 52 weeks number of a year associated to the date of the first monday of the week
For example 1 (week number 1) would be associated to the first monday on the first week of the year.
Week 2 associated to the secondth week of the year, adn so on. The result would be to columns :
Number of the wee and its corresponding date of the monday :
Number_of_the_week----DATE
1----------------------------01/01/2008
2----------------------------14/01/2008
...... etc....
52---------------------------29/12/2008
The request should be something including the year in a "select .(something)... from dual"
Could you suggest me something ?
Thank you for your kind answers !ChristianChristian from France wrote:
It is not so bad except that each date falls on the tuesday instead of the monday of the week. Hmmm, I don't remember you specifying that in your initial requirements.
SQL> ed
Wrote file afiedt.buf
1 with t as (select 2009 as yr from dual)
2 ,off as (select to_number(to_char(trunc(to_date(yr,'YYYY'),'YYYY'),'D'))-1 as offset from t)
3 select rownum as week, trunc(to_date(t.yr,'YYYY'),'YYYY')+((rownum-1)*7)-decode(rownum,1,0,off.offset) as dt
4 from t, off
5* connect by rownum <= 53
SQL> /
WEEK DT
1 01-JAN-09
2 05-JAN-09
3 12-JAN-09
4 19-JAN-09
5 26-JAN-09
6 02-FEB-09
7 09-FEB-09
8 16-FEB-09
9 23-FEB-09
10 02-MAR-09
11 09-MAR-09
12 16-MAR-09
13 23-MAR-09
14 30-MAR-09
15 06-APR-09
16 13-APR-09
17 20-APR-09
18 27-APR-09
19 04-MAY-09
20 11-MAY-09
21 18-MAY-09
22 25-MAY-09
23 01-JUN-09
24 08-JUN-09
25 15-JUN-09
26 22-JUN-09
27 29-JUN-09
28 06-JUL-09
29 13-JUL-09
30 20-JUL-09
31 27-JUL-09
32 03-AUG-09
33 10-AUG-09
34 17-AUG-09
35 24-AUG-09
36 31-AUG-09
37 07-SEP-09
38 14-SEP-09
39 21-SEP-09
40 28-SEP-09
41 05-OCT-09
42 12-OCT-09
43 19-OCT-09
44 26-OCT-09
45 02-NOV-09
46 09-NOV-09
47 16-NOV-09
48 23-NOV-09
49 30-NOV-09
50 07-DEC-09
51 14-DEC-09
52 21-DEC-09
53 28-DEC-09
53 rows selected.
SQL> -
How to get a week number for the year using oracle sql query?
hi everyone,
i have the requirement to find the week number for the calender..
so that week number should start with 01 when the year starts and it should end with week end date(that is first saturday of the january month).. so next week number starts with sunday and ends with saturday ,continously.. in the end date of the year it should not be 'saturday' but week number should end with last date of the year.. again in the next year it should start with '01'.
for example:
01-JAN-13 tuesday 01
02-JAN-13 wednesday 01
03-JAN-13 thursday 01
04-JAN-13 friday 01
05-JAN-13 saturday 01
06-JAN-13 sunday 02
07-JAN-13 monday 02
26-DEC-13 thursday 52
27-DEC-13 friday 52
28-DEC-13 saturday 52
29-DEC-13 sunday 53
30-DEC-13 monday 53
31-DEC-13 tuesday 53
01-JAN-14 wednesday 01
02-JAN-14 thursday 01
how can i achieve this, can anyone please help me out on this..
i have a query that starts with 01 when year starts but it gives problem in the end of the year .. described below with a query..
select mydate,
to_char(mydate,'day') as weekday,
to_char(next_day(mydate,'sunday'),'iw') as week_num
FROM ( SELECT TRUNC (SYSDATE, 'yy') - 1 + LEVEL AS mydate
FROM dual
CONNECT BY LEVEL <= (SELECT TRUNC (ADD_MONTHS (SYSDATE, 24), 'yy')
- TRUNC (SYSDATE, 'yy')
FROM DUAL))
this query gives date, weekday and week_num for 2 years 2013 and 2014,
when i run this query ,at the end of the 2013 it gives the result as,
26-DEC-13 thursday 52
27-DEC-13 friday 52
28-DEC-13 saturday 52
29-DEC-13 sunday 01
30-DEC-13 monday 01
31-DEC-13 tuesday 01
01-JAN-14 wednesday 01
02-JAN-14 thursday 01
for dates 29 ,30,31st it should give 53 .. how can i achieve that using this this query .. can any one help me out on this please...
thanks,
pradeepI tried with the IW ...
it is giving week_id for the year.
select
mydate,
to_char(mydate,'day'),
case when mydate between trunc(mydate,'yyyy') and next_day(trunc(mydate,'yyyy'),'saturday')
then to_number(to_char(mydate,'yyyy')||to_char(trunc(mydate,'yyyy'),'iw'))
when mydate between next_day(trunc(mydate,'yyyy'),'saturday') and trunc(add_months(trunc(mydate,'yyyy'),12)-1,'d')-1
then to_number(to_char(mydate,'yyyy')||to_char(next_day(mydate,'sunday'),'iw'))
when mydate between trunc(add_months(trunc(mydate,'yyyy'),12)-1,'d') and add_months(trunc(mydate,'yyyy'),12)-1
then to_number(to_char(mydate,'yyyy')||to_char(trunc(add_months(trunc(mydate,'yyyy'),12)-1,'d')-1,'iw')+1) end as WEEK_ID
FROM ( SELECT TRUNC (SYSDATE, 'yy') - 1 + LEVEL AS mydate
FROM dual
CONNECT BY LEVEL <= (SELECT TRUNC (ADD_MONTHS (SYSDATE, 24), 'yy')
- TRUNC (SYSDATE, 'yy')
FROM DUAL
)) -
XSLT Mapping: how to calculate Week number of the year from given date
Hi,
I have input as date, i need to know the Week number from that date in XSLT Coding.
for Eg: if date is 29-12-2009 it should give 53rd week of the year.
All answers will be appreciated.
Regards,
MayankHi add this statement to your XSLT Mappping
<xsl:stylesheet version="1.0" xmlns:java="http://xml.apache.org/xslt/java" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="java">
and use <xsl:template name="GetDateInLocal" xmlns:cal="xalan://java.util.GregorianCalendar"> in XSLT Mapping , write your logic.
cheers,
Raj -
How to get a proper week number and MATCHING year number
Java classes such as SimpleDateFormat offer convenient means to find out the correct week number of a given date. Week numbering is locale specific and not always intuitive. For example, Dec 31, 2001 is in week 1 of 2002 in locales where a week starts with Monday or Sunday. Now, if one formats the date using a method such as:
new SimpleDateFormat("'week: 'ww', year: 'yyyy").format(theDate);
this produces result
week: 1, year: 2001
when the typically anticipated value would be "week: 1, year: 2002".
Is there any means to find out the year number, which matches to the given week number for a date? Or do I have to create a kludge myself?
I would be suprised if this feature is not part of Java API, since it seems like a quite common need. Then again, I'm not suprised by surprises in Java API anymore ;)Well, the real problem is just that the rules determining which year the week belongs to are complicated. In some locales, weeks start with Monday, in some Sunday. In some locales year that has 4 or more days of the week "owns" the week, in some locales there might be different rules.
All this complex logic is already implemented in Calendar / SimpleDateFormat / etc classes, so it would be clearly valuable thing to be able to use that code. For example, Calendar.get(YEAR_OF_WEEK_OF_YEAR) or similar. But, it does not seem to be possible.
As I mentioned originally, I can implement my own "kludge" to do this if I have to. This is not nice, since I will be duplicating the functionality already implemented in the calendar classes. Of course, solution is neither as simple as "set calendar to the weeks end" or "set calendar to the weeks start"... -
How to get the week number of year from a Date object?
Hi!
I would like to know the week number of the year from a specified Date.
I dont know how to set the first day of week, and set the minimum days of a week.
I want to use Monday for first day of week, and at least 4 days of month in a week.
For example if its 1st, January is Friday, then the first week starts on 4th, Monday.
Anyone can help?Sorry. I should think before I move.
public static int getWeekOfYear(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setMinimalDaysInFirstWeek(4);
return calendar.get(Calendar.WEEK_OF_YEAR);
} -
IPCC 7 Determine the week number of a month
Hello,
I am working towards determine the week number of month and make appropriate routing changes only for that specific week. I have tried using the trunc(), getdate() and weekday(). But i fail to get the week number of a month, but I believe I have managed to the week number of a year.
The example I have considered is: On Tuesday and Thursdays in second week of every month the calls to be routed to a different skillgroup.
Please let me know if anyone has any suggestion for this.
Thanks,
FYI,
CM 4.1, CRS 3.5, ICM 7.1Hi buddy,
Great stuff!! Your link gave me another hint of the possible solution, I was working on ICM but not sure why i did not consider CRS for this requirement , The CRS has a builtin function, I have used this builtin Methods which provided me what i expected.
The debug on the script resulted the week of the month for today which is "4".
Please let me know your view.
Thanks again! -
How to determine the month from the week number?
Hi all,
in a routine i have the week number in a year and i need to find the month but i don't know the correct FM to use for this.
Is there anyone that had to face a similar problem?
I'm considering that to determine the month it will be used the first day of the week since there are weeks belonging to 2 different months...
Thank you
StefanoHi
If you have a Fiscal Year Variant determined for the week you can use function module PERIOD_DAY_DETERMINE by passing week,fiscal year and fiscal year variant for the week which will return fist and last date.So based on last data you can determine the month.
Regards
Srilaxmi -
Display ISO week number instead of date on x axis in Bar Chart
Hi,
I've created a simple SSRS report based on bar chart that shows several milestones. Everything works fine for me except I’m not able to convert the date into ISO week number format.
I played around with different approaches. I was able to convert the date into an ISO week Format directly on the SQL Server. That
wasn't a problem.
But unfortunately I’m not able to display the week number on the horizontal axis in my Bar Chart. I tried both fields: TaskFinishDate and TaskFinishDateMS...
I would like to show the ISO week number instead of the date within the Bar Chart on the horizontal axis.
Any ideas/hints/help is really appreciated!
Thanks,
MikeHi Mike,
Per my understanding that you want to get the week number of the year based on the field "TaskFinishDate" which is datetime type and display the week number in the x-axis instead of the field "TaskFinishDate", right?
I have check the snapshot you have provided and it seems you have change the format of the datetime field in the x-axis like "dd.MM.YYYY", If you can't make the week number to display correctly in the x-axis, the issue can be caused by you haven't
change the format to Number in the category.
Details information below for you reference:
I assume you have use expression in the Label like below to convert the datatime TaskFinishDate in to ISO week number like below:
=DatePart(DateInterval.WeekOfYear,Fields!TaskFinishDate.Value)
or
=DatePart("ww",Fields!TaskFinishDate.Value)
Right click the X-axis and select the "Horizontal Axis Properties", then click the Number to change the format to "Number" as below:
Preview you will get the weeknumber display in the x-axis correctly.
If you still have any problem, please feel to ask.
Regards,
Vicky Liu
If you have any feedback on our support, please click
here.
Vicky Liu
TechNet Community Support -
Hi all,
Could you suggest me a FM for for finding the week number of a month.
I can see FM which shows week number of an year .But i want the week number with reference to a month.
Thanks
Sam.Hi,
A sample using function DATE_GET_WEEK
Report try05.
DATA: xweek(6) TYPE n,
xdt TYPE d.
xdt = '20050101'.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = xdt
IMPORTING
WEEK = xweek
EXCEPTIONS
DATE_INVALID = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE:/ xdt.
WRITE:/ xweek.
Hope this helps.
Reward if helpful.
Regards,
Sipra -
How do i get the date when enter a week number
Hi, can anyone tell me how do i get the date when enter a week number??
let say, i enter week number 4 and year 2008
result=26-01-2008
thanks..import java.util.Calendar;
public class testCalendar {
public static void main(String args[]){
int year=2008;
int week =5;
Calendar now=Calendar.getInstance();
now.set(Calendar.YEAR,year);
now.set(Calendar.WEEK_OF_YEAR,week);
System.out.println(now.getTime());
hai, anyone know why i can't get the result:27-01-2008
i always get two day later. That is 29-01-2008
no wonder how i change the week number and year.
for example: week=7, year=2007
expected result:11-02-2007
but the result is 13-02-2007
thanks..
Edited by: Angel_Wei on Sep 1, 2008 11:58 PM -
Get week number for day from a list of days within a year..
I am beginning in ORACLE / SQL and wondering how I can use this query to work with a column of Dates that span over a number of years?
Ideally, I would like to use this script to add a number for the week of the year based on this.
Then when a new year begins to start over..
I am referencing an old thread..
TO_CHAR with dates to get week number issue
Here is what I have so far:
I keep getting an error stating "Bind Variable "p_date_beg" is NOT DECLARED"..
Thanks in advance for any help you can provide.
DECLARE
p_date_beg DATE;
BEGIN
SELECT RETRIEVAL_DATE
INTO P_DATE_BEG
FROM OBS_SELECT_LST12_SPG;
WITH TAB AS
(SELECT TO_DATE(TO_CHAR(:p_date_beg,'YYYYMM')||'01','YYYYMMDD') + LEVEL -1 DATE_COL
FROM DUAL
CONNECT BY LEVEL <=TO_NUMBER(TO_CHAR(LAST_DAY(:p_date_beg),'DD')))
SELECT DATE_COL, TO_CHAR(DATE_COL, 'FMDAY') DAY,
(CASE
WHEN TO_CHAR(TRUNC(DATE_COL, 'mm'),'FMDAY') = 'SUNDAY'
THEN TO_NUMBER(TO_CHAR(DATE_COL,'W'))
ELSE CEIL((TO_CHAR(SYSDATE, 'dd') + 1 - TO_CHAR(NEXT_DAY(TRUNC(SYSDATE, 'mm'), 'SUNDAY'), 'dd'))/7)
END) WEEK_NOB
END;hi, referring to this link about ISO week, http://www.epochconverter.com/date-and-time/weeknumbers-by-year.php, here is the code:
/* Formatted on 2012/06/13 06:32 (Formatter Plus v4.8.8) */
WITH t AS
(SELECT MIN (TO_DATE ('20120101', 'rrrrmmdd') + LEVEL - 1)
start_date,
1 week_th
FROM DUAL
WHERE TO_CHAR ( TRUNC (TO_DATE ('20120101', 'rrrrmmdd'), 'mm')
+ LEVEL
- 1,
'FMDAY'
) = 'MONDAY'
AND ( TO_DATE ('20120101', 'rrrrmmdd') + LEVEL - 1 <
TRUNC (NEXT_DAY (TO_DATE ('20120101', 'rrrrmmdd'),
'THU'
OR (TO_DATE ('20120101', 'rrrrmmdd') + LEVEL - 1
BETWEEN TRUNC (NEXT_DAY (TO_DATE ('20120101',
'rrrrmmdd'
'THU'
AND TRUNC (NEXT_DAY (TO_DATE ('20120101',
'rrrrmmdd'
'THU'
+ 7
CONNECT BY LEVEL < 15),
v AS
(SELECT t.start_date + 7 * (LEVEL - 1) start_date,
t.week_th + LEVEL - 1 week_th
FROM t
CONNECT BY LEVEL < 53),
u AS
(SELECT '20120501' dt
FROM DUAL
UNION ALL
SELECT '20120502'
FROM DUAL
UNION ALL
SELECT '20120503'
FROM DUAL
UNION ALL
SELECT '20120504'
FROM DUAL
UNION ALL
SELECT '20120505'
FROM DUAL
UNION ALL
SELECT '20120506'
FROM DUAL
UNION ALL
SELECT '20120507'
FROM DUAL
UNION ALL
SELECT '20120508'
FROM DUAL
UNION ALL
SELECT '20120509'
FROM DUAL)
SELECT *
FROM u, v
WHERE TO_DATE (u.dt, 'rrrrmmdd') BETWEEN v.start_date AND (v.start_date + 6);output:
DT START_DATE WEEK_TH
20120501 30/04/2012 18
20120502 30/04/2012 18
20120503 30/04/2012 18
20120504 30/04/2012 18
20120505 30/04/2012 18
20120506 30/04/2012 18
20120507 07/05/2012 19
20120508 07/05/2012 19
20120509 07/05/2012 19 -
DATE FROM THE GIVEN WEEK NUMBER AND YEAR
hi to all
With weeknr, yearnr i need to find STARTDATE (first day of the week), ENDDATE (last day of the week) The first day of the week is always a Monday.
example 44 2007
week nr is 44
year is 2007
how to find it.
is there any standard function module to find.
regards
prathaphi prathap,
WEEK_GET_FIRST_DAY For a given week (YYYYMM format), this function returns the date of the Monday of that week.
try using this function module...
some other function modules may be helpful...
DATE_COMPUTE_DAY Returns a number indicating what day of the week the date falls on. Monday is returned as a 1, Tuesday as 2, etc.
DATE_GET_WEEK will return the week that a date is in.
DATE_IN_FUTURE Calculate a date N days in the future.
DAY_ATTRIBUTES_GET Return useful information about a day. Will tell you the day of the week as a word (Tuesday), the day of the week (2 would be Tuedsay), whether the day is a holiday, and more.
reward if helpful
regards,
sravanthi. -
Get week ending date from Year and Week Number
I would like to display the week ending date in a Report.
My dataset query has grouped the results by year and week number, so I am trying to construct the week ending date from year and week number.Week end date can be got as below
=DateAdd(DateInterval.WeekOfYear,CInt(Fields!WeekNumber.Value) -1,DateAdd(DateInterval.Year,(Cint(Fields!Year.Value) - 1900),CInt("12/31/1899")))
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Getting date using week number and year
hi!
how can i get the date for a given year using a given week number?
assuming that the first day will be sunday?
for example..
the input year is 2006,
then the week number is 30
the result should be july 23 2006...
please help.. Thanks!play a little with the Calendar class. You might need some setters and maybe the add method to scroll to the previous Sunday.
Maybe you are looking for
-
2 Spider diagrams, only one displayed in Crystal Reports Viewer 2008
Hi, I have two Spider diagrams in the report. One shows values for this and another for previous year. The second diagram is placed on top of the first. The diagram below has white background and the diagram above has transparent background. Everythi
-
hi fellas I've got quite a stressing problem with my applets. When I load them in the appletviewer there is no problem, idem in Netscape 7. But when I try with IE I only obtain a grey rectangle. I thought I had written something wrong and I downloade
-
IOS 5.0.1 battery issues on 3GS
So I updated to 5.0.1 this afternoon, and my battery was a little low. I put it on charge for a little while. Before I had to leave work, since leaving work an hour ago, my phone has gone from 27% to 4%. In the last ten minutes alone it's gone from.
-
Hello. After using a Bold 9900 I just spent the passport. Wonderful tool! However I miss: 1 during a call to record the online contact directly on the screen as on the 9900 2: to insert html email signature. Y solution and is it expected in the futur
-
Thumbnails not showing when camera connected and ready to import
Whenever I connect my camera, iPhone, iPod, etc to my iMac - iPhoto recognizes the device, but all I see is dotted lines for the thumbnails when it is ready to import. I can import the photos no problem; iPhoto even recognizes duplicates. It is more