Get week number for any given date
How to get a week number in Java?
/ ====================================================
Method: Get the desired Date format for the date
Developed By: Sandip Waghole [29-Jan-2010]
==================================================== /
public String getWeekNo(String strDate)
// input Date Format : M/dd/yyyy
int weekNo=0,i=0;
String strWeekNo=null;
int noOfDaysInTheYear=365;
int WEEK_STARTS_ON = 1; // Define the day on which week starts Sunday/Monday 1:Sunday 2:Monday
int firstDayNoInFirstWeekOfPresentYear=0; // Inititalize teh day on which week is starting in present year
int firstDayOfPresentYear=0; // Inititlize the 1st day of the present year whether Sunday/Monday/.....
int[] monthDaysArray = {31,28,31,30,31,30,31,31,30,31,30,31}; // Define array of the days as per months
int todaysDayNoInPresentYear=0;
int daysLateByFirstWeekStartedAfterYearStarted=0;
int intTemp=0;
//strDate="08/24/2000"; // For test purpose
StringTokenizer strDateTok = new StringTokenizer(strDate, "/ ");
int month = Integer.parseInt(strDateTok.nextToken());
int day= Integer.parseInt(strDateTok.nextToken());
int year = Integer.parseInt(strDateTok.nextToken());
GregorianCalendar cal = new GregorianCalendar();
// Check if present year is leap year
boolean boolIsLeapYear = cal.isLeapYear(year);
// If it is boolean year then add 1 to total days in the year & add one more day to february
if(boolIsLeapYear)
noOfDaysInTheYear=noOfDaysInTheYear+1;
monthDaysArray[1]=monthDaysArray[1]1;
// Find the 1st day of this year
Calendar calObj = new GregorianCalendar(year, Calendar.JANUARY, 1);
firstDayOfPresentYear = calObj.get(Calendar.DAY_OF_WEEK);
int intRemoveNoOfDaysFromWeek=0;
// # Find the day no of prsent day
for(i=0;i<month;i+) // get no of days till present year
intTemp = intTemp monthDaysArray;
todaysDayNoInPresentYear = intTemp - (monthDaysArray[month-1]-day);
if(firstDayOfPresentYear==6 || firstDayOfPresentYear==7) // If first Day is Friday or Saturday then it is week
// Identify the the day no on which 1st week of present year is starting
firstDayNoInFirstWeekOfPresentYear = 7 - firstDayOfPresentYear WEEK_STARTS_ON 1;
// Find delay in the 1st week start after r=the year start
daysLateByFirstWeekStartedAfterYearStarted = firstDayNoInFirstWeekOfPresentYear - 1;
// Now week is starting from Sunday
weekNo = (Integer)((todaysDayNoInPresentYear-daysLateByFirstWeekStartedAfterYearStarted)/7);
// Find the day no of today
intTemp = (todaysDayNoInPresentYear-daysLateByFirstWeekStartedAfterYearStarted) % 7;
if(intTemp > 0)
weekNo=weekNo+1;
else
weekNo=weekNo;
else
// 1st week is starting on 1st Of January
firstDayNoInFirstWeekOfPresentYear=firstDayOfPresentYear;
// Remove no. of days from the 1st week as week is starting from odd Sunday/Monday/Tuesday/Wednesday/Thursday
intRemoveNoOfDaysFromWeek = 7-firstDayOfPresentYear 1; // 1 added as include start day also
// So one week will be added in no. of weeks
weekNo = (Integer)((todaysDayNoInPresentYear-intRemoveNoOfDaysFromWeek)/7);
// Find the day no of today
intTemp = (todaysDayNoInPresentYear-intRemoveNoOfDaysFromWeek) % 7;
weekNo = weekNo +1; // As 1st weeks days are reduced from the todays day no in the year
if(intTemp > 0)
weekNo=weekNo+1;
else
weekNo=weekNo;
// Remove the no. of days from the week 1
strWeekNo=Integer.toString(weekNo);
return strWeekNo;
// Any issues please mail on [email protected]
Similar Messages
-
ABAP Get Week Number for a Given Date.
Hi All,
I want to calculate week number for given date.
SAP has provided function modules like DATE_GET_WEEK.. Etc are giving week number. taking default start day as Monday. But for my requirement is calculate week number based on start day as Sunday.
Please let me know if we have any custom logic ??
Thanks & Regards
Vasu YadavHi Vasu,
SAP standard functionality takes MONDAY as first day.
But if you want then you can change it to SUNDAY by implementing BADI CALENDAR_DEFINITION. Create a new implementation for method IF_CALENDAR_DEFINITION~GET_FIRST_DAY_OF_WEEK and assign value as SUNDAY.
Hope it solves your problem.
Thanks
Saurabh Kabra -
Getting the week number for a given date
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for 64-bit Windows: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
Hello all.
I am currently migrating our product from SQL SERVER to ORACLE and have the following issue.
Basically I'm just trying to get the year week number for a given date but I'm having trouble with Oracle as it seems to think that the weeks run from Thursday to Thursday?. I presume this is something to do with the fact that the first day of the year was Thursday?
e.g.
SQL SERVER:
select DATEPART(wk, '2009-10-24') as Sat -- 43 - correct
select DATEPART(wk, '2009-10-25') as Sun -- 44 - correct
select DATEPART(wk, '2009-10-26') as Mon -- 44 - correct
select DATEPART(wk, '2009-10-27') as Tue -- 44 - correct
select DATEPART(wk, '2009-10-28') as Wed -- 44 - correct
select DATEPART(wk, '2009-10-29') as Thu -- 44 - correct
select DATEPART(wk, '2009-10-30') as Fri -- 44 - correct
select DATEPART(wk, '2009-10-31') as Sat -- 44 - correct
select DATEPART(wk, '2009-11-1') as Sun -- 45 - correct
select DATEPART(wk, '2009-11-2') as Mon -- 45 - correct
select DATEPART(wk, '2009-11-3') as Tue -- 45 - correct
select DATEPART(wk, '2009-11-4') as Wed -- 45 - correct
select DATEPART(wk, '2009-11-5') as Thu -- 45 - correct
ORACLE:
SELECT to_char(to_date('24-OCT-2009'), 'ww') as Sat from dual; -- 43 correct
SELECT to_char(to_date('25-OCT-2009'), 'ww') as Sun from dual; -- 43 incorrect - should be 44
SELECT to_char(to_date('26-OCT-2009'), 'ww') as Mon from dual; -- 43 incorrect - should be 44
SELECT to_char(to_date('27-OCT-2009'), 'ww') as Tue from dual; -- 43 incorrect - should be 44
SELECT to_char(to_date('28-OCT-2009'), 'ww') as Wed from dual; -- 43 incorrect - should be 44
SELECT to_char(to_date('29-OCT-2009'), 'ww') as Thu from dual; -- 44 correct
SELECT to_char(to_date('30-OCT-2009'), 'ww') as Fri from dual; -- 44 correct
SELECT to_char(to_date('31-OCT-2009'), 'ww') as Sat from dual; -- 44 correct
SELECT to_char(to_date('1-NOV-2009'), 'ww') as Sun from dual; -- 44 incorrect - should be 45
SELECT to_char(to_date('2-NOV-2009'), 'ww') as Mon from dual; -- 44 incorrect - should be 45
SELECT to_char(to_date('3-NOV-2009'), 'ww') as Tue from dual; -- 44 incorrect - should be 45
SELECT to_char(to_date('4-NOV-2009'), 'ww') as Wed from dual; -- 44 incorrect - should be 45
SELECT to_char(to_date('5-NOV-2009'), 'ww') as Thu from dual; -- 45 correct
Now I don't want to get into a discussion with regard to locales etc.
In my world (and is seems SQL SERVER's) the first day of the week is Sunday and the last Saturday.
Is there some NLS_? setting or something that I'm missing?
thanks for any help on this.
AndyThis is what you need.
SELECT ceil(( 7+(trunc(to_date('25-OCT-2009'),'d')-trunc(to_date('25-OCT-2009'),'Y')) )/7) FROM dual
HTH!!!
--tested all these statements.
Works as you wish!!
SELECT ceil(( 7+(trunc(to_date('24-OCT-2009'),'d')-trunc(to_date('24-OCT-2009'),'Y')) )/7) as Sat from dual;
SELECT ceil(( 7+(trunc(to_date('25-OCT-2009'),'d')-trunc(to_date('25-OCT-2009'),'Y')) )/7) as Sun from dual;
SELECT ceil(( 7+(trunc(to_date('26-OCT-2009'),'d')-trunc(to_date('26-OCT-2009'),'Y')) )/7) as Mon from dual;
SELECT ceil(( 7+(trunc(to_date('27-OCT-2009'),'d')-trunc(to_date('27-OCT-2009'),'Y')) )/7) as Tue from dual;
SELECT ceil(( 7+(trunc(to_date('28-OCT-2009'),'d')-trunc(to_date('28-OCT-2009'),'Y')) )/7) as Wed from dual;
SELECT ceil(( 7+(trunc(to_date('29-OCT-2009'),'d')-trunc(to_date('29-OCT-2009'),'Y')) )/7) as Thu from dual;
SELECT ceil(( 7+(trunc(to_date('30-OCT-2009'),'d')-trunc(to_date('30-OCT-2009'),'Y')) )/7) as Fri from dual;
SELECT ceil(( 7+(trunc(to_date('01-NOV-2009'),'d')-trunc(to_date('01-NOV-2009'),'Y')) )/7) as Sat from dual;
SELECT ceil(( 7+(trunc(to_date('02-NOV-2009'),'d')-trunc(to_date('02-NOV-2009'),'Y')) )/7) as Sun from dual;
SELECT ceil(( 7+(trunc(to_date('03-NOV-2009'),'d')-trunc(to_date('03-NOV-2009'),'Y')) )/7) as Mon from dual;
SELECT ceil(( 7+(trunc(to_date('04-NOV-2009'),'d')-trunc(to_date('04-NOV-2009'),'Y')) )/7) as Tue from dual;
SELECT ceil(( 7+(trunc(to_date('05-NOV-2009'),'d')-trunc(to_date('05-NOV-2009'),'Y')) )/7) as Wed from dual;
SELECT ceil(( 7+(trunc(to_date('06-NOV-2009'),'d')-trunc(to_date('06-NOV-2009'),'Y')) )/7) as Thu from dual;
Cheers!!!
Bhushan
Edited by: Buga on Oct 29, 2009 10:46 AM -
How to get the week number for a given date?
hi guys,
what is coding to get the week number for a given date?
For example, 1/1/05 is week 1. then 8/1/05 is week 2.The second parameter to pass to the method is supposed to be one of the month constants JANUARY - DECEMBER. It happens to be that their numerical values are 0-11, not 1-12, so your "12" refers to the "13th" month of the year.
givenDate = new GregorianCalendar(2003, Calendar.DECEMBER, 31);
If you want to construct dates and times from strings like you seem to be, look into SimpleDateFormat http://javaalmanac.com/egs/java.text/ParseTime.html
(even still I got WEEK_OF_YEAR as 1 which is true but not really what I expected, excuse my previous reply but I wanted to check the facts before posting this) -
Any FM to get count of each week day for the given date range
Hi guys,
Any FM to get count of each week day for the given date range?
eg: If i give 14/07/2008 to 14/08/2008
I need to find how many Mondays, tuesdays...sundays in this given date range.
If not single FM is available, any logic that gives above result is also appreciated.
Thanks,
Vinod.hi Vinod,
this is not a full solution, I just give you a basic idea:
DATA : lv_start TYPE sy-datum VALUE '20080714',
lv_end TYPE sy-datum VALUE '20080814'.
WHILE lv_start LE lv_end.
CALL FUNCTION 'FTR_DAY_GET_TEXT'
EXPORTING
pi_date = lv_start.
* IMPORTING
* PE_DAY_TEXT1 =
* PE_DAY_TEXT2 =
* PE_DAY =
* you have to summarize the output here somehow...
lv_start = lv_start + 1.
ENDWHILE.
hope this helps
ec -
How to find the Day on a Week for any given Date
Hi..... I need your help to find out the Day on a Week for any given Date .
Say if the Date is 31/12/2009 , what would be the Day on a Week for this Date.
Are there any fucntions available to determine the same?
Please let me know....Thanks in Advance
Regards
SmitaHi ,
You can using the following peice of code to get the Day of a Week for the given date :
Calendar now = Calendar.getInstance();
System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1)
+ "-" + now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR));
//create an array of days
//Day_OF_WEEK starts from 1 while array index starts from 0
String[] strDays = new String[]{"Sunday", "Monday", "Tuesday", "Wednesday", "Thusday", "Friday", "Saturday" };
String day_of_week = strDays[now.get(Calendar.DAY_OF_WEEK) - 1];
System.out.println("Current day is : " + strDays[now.get(Calendar.DAY_OF_WEEK) - 1] );
Edited by: Ritushree Saha on Jun 4, 2009 1:09 PM -
Block stock calculation from mseg table for any given date.
I am calculating stock from mseg table for any given date. Not just month end stock or current stock. It could be back date also. It is tallying also with MB5B stock report of that date. Now I have to bifurcate that stock into unrestricted stock, quality stock and block stock.
I have checked INSMK and ZUSTD field in mseg table, but could not concluded. Should I check movement type wise? Block/ Quality stock could be transferred into unrestricted stock also. That also I have to take care.
Can anyone clearly explain how the stock type posting takes place in mseg table when goods receipt as block / quality stock and when the same goods transferred in unrestricted stock, what are the reference indication.DATA : LIST_TAB TYPE TABLE OF ABAPLIST.
DATA: BEGIN OF VLIST OCCURS 0,
FIELD1(5) TYPE C,
FIELD2(19) TYPE C,
FIELD3(16) TYPE C,
FIELD4(17) TYPE C,
FIELD5(25) TYPE C,
FIELD6(24) TYPE C,
FIELD7(25) TYPE C,
FIELD8(25) TYPE C,
END OF VLIST.
TYPES : BEGIN OF ITAB,
MATNR(18) TYPE C,
WERKS(5) TYPE C,
END_MENGE(20) TYPE C,
END OF ITAB.
DATA : ITAB TYPE STANDARD TABLE OF ITAB WITH HEADER LINE,
WA_TAB TYPE ITAB.
----submit command to run mb5b in the background and -
----push the data into an internal table -
" Calling MB5B for displaying the Closing Stock
SUBMIT RM07MLBD USING SELECTION-SCREEN '1000'
WITH DATUM BETWEEN S_DATE-LOW AND S_DATE-HIGH
WITH MATNR IN S_MATNR WITH WERKS IN S_WERKS
WITH BWART-LOW = '601' EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = LIST_TAB
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
TABLES
LISTASCI = VLIST
LISTOBJECT = LIST_TAB
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3.
LOOP AT VLIST WHERE FIELD1 CS '|'.
CHECK SY-TABIX GE 4.
MOVE : VLIST-FIELD1+1(4) TO ITAB-WERKS,
VLIST-FIELD2+1(18) TO ITAB-MATNR,
VLIST-FIELD8 TO ITAB-END_MENGE.
APPEND ITAB.
ENDLOOP.
This is the program to call MB5B and the standard program and use the following settings for the closing stock opening stock and block stock -
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 -
How to get the date of first day of a week for a given date
Hi gurus
can any one say me how to get the date of first day(date of Sunday) of a week for a given date in a BW transformations. For example for 02/23/2012 in source i need to get 02/19/2012(Sunday`s date) date in the result. I can get that start date of a week using BWSO_DATE_GET_FIRST_WEEKDAY function module. But this function module retrieves me the start date as weeks monday(02/20/2012) date. But i need sundays(02/19/2012) date as the start date. So it would be really great if anyone sends me the solution.
Thanks
RavHi,
The simplest way would be to subtract 1 from the date date which you are already getting in transformation routine, but instead of doing that subtraction manually which might need bit of errort, you can simply use another FM to subtract 1 from given date.
RP_CALC_DATE_IN_INTERVAL
Regards,
Durgesh. -
FM that gives number of day in the week for the given date
Hi,
I have a requirement to find the number of the day in a week for the given date. For example, 07/09/2009 is Thursday & 4th day of the week. Is there any FM to accomplish this task?
Appreciate your help in Advance.
Thanks,
Kannan.Hi Kannan,
ISH_GET_DAY_OF_WEEK.
Regards,
Dilek -
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
)) -
How to get start date of the period for a given date from cube
I have a situation where i need to find the start day of the period for a given date. is there a way to know that. i want to use that in my report. i enter the date from my report(i have date parameter), depends on the date, i want to display the start day
of the period. how can i write expression for that in my report?
ramHi ramprasad74,
According to your description, you are using Analysis Services as a data source for the report, the cube has hierarchy: Fyear, FQuarter, FPeriod, fweek, Fdate. You want to add a date parameter to the report, after you changed value of the parameter, the
report will return the first day of FPeriod.
To achieve your goal, we need to add a parameter to the report, then use the parameter in mdx query. For detail information, please refer to the following steps:
In the Report Data pane, right-click on a dataset created from a SQL Server Analysis Services data source type, and then click Query. The MDX query designer opens in Design mode.
On the toolbar, click Design to toggle to Query mode.
On the MDX query designer toolbar, click Query Parameters symbol. The Query Parameters dialog box opens.
In the Parameter column, click <Enter Parameter>, and then type the name of a parameter.
In the Dimension column, choose a value from the drop-down list.
In the Hierarchy column, choose a value from the drop-down list.
In the Default column, from the drop-down list, select a single value.
Click OK.
In query designer dialog box, type the mdx query like below:
with member [Measures].[FirstChild]
as
[Date].[Fiscal].currentmember.parent.firstchild.name
select {[Measures].[FirstChild]} on 0,
[Date].[Fiscal].[Date].members on 1
from
( SELECT ( STRTOSET(@ParameterName, CONSTRAINED) ) on 0
from
[Cube]
Here are relevant threads you can reference:
https://social.msdn.microsoft.com/forums/sqlserver/en-US/c7146ac3-40ea-4d53-b321-c707aebbd405/how-to-pass-date-parameter-to-mdx-query
https://social.msdn.microsoft.com/forums/sqlserver/en-US/fd12a865-bc90-4a65-af42-ce38a8cfa29b/pass-date-time-parameter-to-mdx-query-ssrs
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
If you have any feedback on our support, please click
here. -
Find the 'DAY' for a given 'DATE'
Hi Folks,
I need a help regarding finding the day for a given date.
My requirement is that..,
If I enter a date using 'parameters', it should write the 'day' for the corresponding date.
To be more specific.....,
if I enter date as ' 07/15/2008 ' it should return me the day as 'Tuesday'.
Regards,
Naveen GHI,
FM LIST WITH RESPECT TO DAY, WEEK, AND MONTH.
CALCULATE_DATE : Calculates the future date based on the input .
DATE_TO_DAY : Returns the Day for the entered date.
DATE_COMPUTE_DAY : Returns weekday for a date
DATE_GET_WEEK : Returns week for a date
RP_CALC_DATE_IN_INTERVAL : Add days / months to a date
MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.
END_OF_MONTH_DETERMINE_2 : Determines the End of a Month.
HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.
FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
MONTH_NAMES_GET : Get the names of the month
WEEK_GET_FIRST_DAY : Get the first day of the week
HRGPBS_HESA_DATE_FORMAT : Format the date in dd/mm/yyyy format
SD_CALC_DURATION_FROM_DATETIME : Find the difference between two date/time and report the difference in hours
L_MC_TIME_DIFFERENCE : Find the time difference between two date/time
HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months
LAST_DAY_OF_MONTHS : Returns the last day of the month
DATE_CHECK_PLAUSIBILITY :Check for the invalid date.
Reward points if useful,
siri -
Name of users of a particular Tcode for a given date range
Hi experts,
I am making an alv where inputs will be
1> T_code(as parameter)
2> Date Range(as Select options)
I have to display the following fields:::
1> User name
2> Frequency of use the Tcode for the given Date range.
Please give me the tables where I can get the relation of those fields.
N.B. I know the transaction AL08 and SM04.But it won't solve my purpose.
Thanx in advance,
Sourav>
SOURAV PAUL wrote:
> Hi experts,
> I am making an alv where inputs will be
> 1> T_code(as parameter)
> 2> Date Range(as Select options)
by creating the report As per your this requirement you need not to create any Bulk on your SAP.Just use STAD/STAT transaction they are availabe for this purpose.
and more you may track by security log audit by SM20 get these details.
i'm worried about tables which sre storing these details. -
Query to get Week number Pls help
I need to get week number of the current year in the format 2008-W47 ( this is for sysdate
when i try
select to_CHAR(sysdate,'YYYY'||'-IW')
FROM DUAL
i get 2008-47
but in the format 2008-W47
Help
sSQL> select to_CHAR(sysdate,'YYYY')||'-W'||to_char(sysdate,'IW') from dual
2 /
TO_CHAR(
2008-W47
Maybe you are looking for
-
How can I send a large .MOV file to a USB?
We had an event a few days ago, and made a movie with iMovie, when I finally finished making it and adding what i wanted and edited to my like I exported it. The file is currently 9.86GB. I have a 32GB USB thumbdrive but everytime I try to "drag and
-
How can i delete my SECONDARY home screen?
ok I went to the genius bar at thee apple store and they helped me Create a new Apple ID, Then a new Itunes store ID and a new Administrator Name and password, then they explain because its time consuming how to go to Sys Prefs-->Accounts-->Click + b
-
I cannot find my finder sidebar
I cannot find my finder sidebar
-
Server-side flash player version detection
Does anyone know of a method to pull the users flash-player version number (the entire thing, not just ">6" or "9" but "9,0,115,0") that does not use browserhawk. We are building a troubleshooting page for our LMS built on ASP.net, and do not want to
-
Eliminating fine lines around composited artwork
I'm using PP CS5 on Win7 x64. I have a number of JPEGS I've imported into my project and placed on various tracks to composite them into the frame. They're all on white backgrounds and the project is also set on a white background. Everything look