Current week dates
Hello
Can anybody help me out in getting the current weeks dates. I know only know how to get todays date.
Thanks
Sravanti
You can use the Calendar class to help you with getting dates:
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_WEEK, 0);
Date[] thisWeek = new Date[7];
for(int idx = 0; idx < 7; idx++)
thisWeek[idx] = calendar.getTime();
calendar.add(Calendar.DAY, 1);
}It should be quite obvious what's going on in there.
A new Calendar is created. By default it has the current date. We set it to be the first day of the current week. We then keep adding one day to it, storing the resultant Date (given by getTime()!).
Hope this helps.
Similar Messages
-
Hi I'm trying to put a query together that shows the dates, from monday to saturday for the current week. So for example if it's friday it has to show me monday / tuesday / wednesday / thursday and the current friday.
Does anyone know how to accomplisch this with the use of sysdate?
This is what I got now.
select trunc(trunc(sysdate,'y') + (:fw * 7),'iw') "Monday",
trunc(trunc(sysdate,'y') + (:fw * 7),'iw')+1 "Tuesday",
trunc(trunc(sysdate,'y') + (:fw * 7),'iw')+2 "Wednesday",
trunc(trunc(sysdate,'y') + (:fw * 7),'iw')+3 "Thursday",
trunc(trunc(sysdate,'y') + (:fw * 7),'iw')+4 "Friday"
from dual
but I need to get this in one column and that it wil automaticly fill in the current week date
Message was edited by:
SilvertraXSQL> select to_char(next_day(sysdate,'sunday')-7+rn,'day')
2 from
3 (select rownum rn
4 from dual
5 connect by level <= (next_day(sysdate,'sunday') - sysdate)+1)
6 /
TO_CHAR(N
monday
tuesday
wednesday
thursday -
How to get current week data only
Dear All,
I'm running a report from January 2014 till date.
I want a variable that helps me to show only the current week data.
Please help ASAP if anyone available now.
Thanks In AdvanceHi
You should create a dynamic prompt @ universe level or @ Business layes with @Prompt.
create a filter in universe with below code
DATE BETWEEN
case
when @Prompt('Week Start Date:','A','<LOV>',,'Week Start Date')='Week Start Date' then getdate()-7
else @Prompt('Week Start Date:','A','<LOV>',,) end
AND
case
when @Prompt('Enter Date:','A','<LOV>',,'Current Date')='Current Date' then getdate()
else @Prompt('Enter Date:','A','<LOV>',,) end
PS: syntax will work for SQL server. Change syntax for other databases
Now use the filter in the report and you will get the current date data
Regards
Anil -
Hello Experts,
I have a day name column and 3 measures query count, row count... and the requirement i have is, i need to get the data about the current week it means when i run the report now i should get only Monday of this week and its row count, query count.. and when i run it tomorrow i should get Monday, Tuesday and when i run it on wednesday Monday, tuesday, Wednesday and so on. Please let me know if i am not clear with my presentation. I am wondering how i can achieve this.
Thanks,
RCThanks for your response. I tried your code in the date column filter but its not working, i am getting error not sure if i can just take it and use the same code in the filter criteria. To be more clear i have Day name(Monday, Tuesday..), Day number(for sunday its 1,Monday 2,tuesday 3..) and Date (in the format 11/6/2011...) and the rest are measures,. Basically this is a system generated report like stats report. My requirement is i need to get the current week data as i mentioned earlier if i run the report today it should give me the information only from sunday to today. Please let me know how i can achieve this.
Thanks,
RC
Edited by: user1146711 on Nov 8, 2011 8:55 AM -
Getting previous weeks data based on parameters entered
I am using CRXI. I have a RT that gives me the current week data but I need to be able to report on previous week data based on the paraments so if I enter dates between sunday and saturday of one week it will report on those data plus the same days of the previous week. I looked at the lastfullweek function, but not sure how to implement it in my scenerio. any ideas?
RalphThat worked, thankyou. My next question along the same lines, is I am also having a third column that will indicate the percent change. for example
Current Previous % Change
97 108
I am trying to computer the % change between curent and previous basically it would look at previous as being the control and computer positive or negative based on what current is. I can do the math formulas, but I'm not sure what to comute to find the % change.
Ralph -
How to get data for current week and previous week using customer exit in Bex.
Hi everyone,
I have a scenario in which I need to display data for current week and previous week (based on "sy_datum" the program has to calculate current week and previous week) in Bex using Customer exit. I have created one variable in Bex Query Designer and I have written code for the variable in CMOD. But it is not working fine, (I know that we can do the same by using offset value in Bex). Can some one guide me how to achieve my requirement using customer exit.
Thanks in Advance,
G S Ramanjaneyulu.Hi krishna,
Thanks for your quick reply, can you have a look at my code,
case i_vnam.
WHEN 'ZPWK_CWK'.
ranges : pre_week for sy-datum.
data : start_date type DATS,
end_date TYPE dats .
************FM TO GET FIRST DATE OF CURRENT WEEK ************************
CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY'
EXPORTING
DATE_IN = sy-datum
IMPORTING
DATE_OUT = start_date. " WEEK FIRST DATE
end_date = START_DATE + 6. " WEEK LAST DATE
END_DATE = START_DATE - 1. " PREVIOUS WEEK END DATE
START_DATE = START_DATE - 7. " PREVIOUS WEEK START DATE
**********PREVIOUS WEEK DATES IN PRE_WEEK******************
pre_week-SIGN = 'I'.
pre_week-option = 'BT'.
pre_week-LOW = START_DATE.
pre_week-HIGH = END_DATE.
APPEND pre_week.
CLEAR : START_DATE,END_DATE.
endcase.
Regards,
G S Ramanjaneyulu. -
I recently upgraded to iWork v9.0.3, but when I access each applications the versions are different (i.e. Pages V.4.1, Numbers V2.6, Keynote V5.1.1) with a install date of 3/18/09 -- which is not the current install date of 2 weeks ago. Shouldn't Pages, Numbers, and Keynote show version 9.?? My MAC confirned installation of v9.0.3 and even accepted the software code. With this discrepancy, how can I determine if the latest was installed and operational? I even downloading v9.0.4, 9.0.5, and 9.1. When I tried installing these downloads it popped up note stating that a later version of Keynote was already installed.
You used the data. Verizon can not see what it was sued for. However your phone can see whats apps used the data. go to settings-data usage- there will be a place that says data usage cycle. line the dates up with your cycle. then there will be a bar graph below that extend bother white bars one all the way to the left and one all the way to the right. after those are extended below that will be a list of apps, there should be one that used over 2 gb and that will show you what app used that data in her purse
-
How to get date range of Current week
Hi Gurus,
I need to create report of current(this) week manual bills created by one user. I have date Field called CREAT_DATE.Based on this date column i need to create report.
Could anybody help to get this query.
Example:
select .....
from ....
where
CREAT_DATE
Thank You
VikramIt kind of depends on your definition of "current week". If you mean something like the last 7 days, then
SELECT columns
FROM table
WHERE creat_date BETWEEN TRUNC(sysdate - 7) and TRUNC(sysdate +1)would do it.
If you mean Monday until today, then:
SELECT columns
FROM table
WHERE creat_date BETWEEN NEXT_DAY(TRUNC(sysdate - 7), 'MONDAY') and TRUNC(sysdate +1)Read up on the various date functions for other possibilities.
TTFN
John -
Current date, first day of month, last day of month, current week, current
Hi All,
may be the question will sounds basic for your guys, I am connecting via MDX a cognos reportnet on a BW 3.0B..due to loads of limitations on filtering via MDX on 'business date/time functions' , I would need to create in the infoqueries that are my data sources, the following additionnal objects:
- current date
- first day of current month
- last day of current month
- current week
- current year
I do not want prefiltered infoqueiries but object with these single values so that from reportnet I can have something like: OCALDAY between 'first day of current month' and 'last day of curent month'
Is there standard fonction for this under BW/BEX or if we need to developp functions has nayone some code examples.
thanks a lot for your great input
DavidHi,
In universe level if you want implement the requirede functions then you have to write custom sql and if you want to implement them in Reporting level then most of the functions are available to you. e.g. Quarter,Month, Year, Current Date....
Cheers,
Suresh A. -
How to calculate start date and last date for current week
Dear All.
i want to calculate the start of the current week as well as the last date of the current week, our week start from Saturday and ends of Friday i.e. Saturday is the first day of the week and Friday is the last day of the week.
How can i acheive this in universe Designer?.
Please help...Hi
the formulas in webi will be as follows
for startdate
=RelativeDate(LastDayOfWeek(CurrentDate());-8)
for enddate:
=RelativeDate(LastDayOfWeek(CurrentDate());-2)
Regards,
Ranganath -
Get the Current Quarter and Current Week from date
Hi,
I want to get the Current quarter and Current week from a given date, which function modules should i use?
I tried using function module - 'HR_99S_GET_QUARTER' for getting the quarter but it is throwing an error while loading data. Moreover it doesnt exist in BI7.
Similarly for current week.
Please help. Sample code snippets would be appreciated.
Thanks
JayaYou can use FORM time_conversion wich is the one used by standard in Update Rules:
You can select whether convert 0CALDAY to 0CALWEEK or whatever infobject formats you prefer...
perform time_conversion
using '0CALDAY'
'0CALMONTH'
p_input_date
l_fscvtval
changing RESULT
c_t_idocstate
c_subrc
c_abort.
if c_subrc <> 0 or c_abort <> 0.
exit.
endif.
form time_conversion
using i_timnm_from type rsiobjnm
i_timnm_to type rsiobjnm
i_timvl
i_fiscvarnt type t009b-periv
changing e_timvl
c_t_idocstate type rsarr_t_idocstate
c_subrc like sy-subrc
c_abort like sy-subrc. "#EC *
data: l_timvl type rsd_chavl,
l_result type rsd_chavl.
IF i_timvl CO ' 0'.
CLEAR e_timvl.
EXIT.
ENDIF.
l_timvl = i_timvl.
CALL FUNCTION 'RST_TOBJ_TO_DERIVED_TOBJ'
EXPORTING
i_timnm_from = i_timnm_from
i_timnm_to = i_timnm_to
i_timvl = l_timvl
I_FISCVARNT = i_fiscvarnt
I_BUFFER = rs_c_true
IMPORTING
E_TIMVL = l_result
EXCEPTIONS
INCOMPATIBLE_TOBJS = 1
NO_INPUT_VALUE = 2
FISCVARNT_MISSING = 3
INPUT_NOT_NUMERIC = 4
WRONG_DATE = 5
WRONG_FISCPER = 6
X_MESSAGE = 7
OTHERS = 8
e_timvl = l_result.
ENDFORM. "TIME_CONVERSION -
Current week/current Month/YTD data based on user response
Hi
I have one attribute request_created_date
Based on this i want to create one more attribute which will have lovs as week(Request_created_date for current week),monthly(Request_created_date for current week),
YTD(Request_created_date for current year to date).
Now i want to use this new attribute (Having LOV as week/Month/YTD) as a report prompt so that user itself can select whether he wants to see
week/month/YTD data in report.
To Add to this :
Req is something like this if user select week , Req_created_dates should be filtered for all the dates of cureent week.
Req is something like this if user select month , Req_created_dates should be filtered for all the dates of cureent month.
Req is something like this if user select Year , Req_created_dates should be filtered for all the dates of cureent year.
How can i achieve this?Add One variable
Time_Data ="Weekly"
Create Input control (Radio Button)
Use Custom LOVs (Add Weekly , Monthly , Yearly ).
Set Default (Weekly).
Now Create Another Variable
User_Want = ReportFilter([Time_Data])
Now filter your Report for week , Month or Year (as per Selection) using If else Statement .
For eg.
For Week
[Created_Date] Between RelativeDate(CurrenDate();-7) And CurrentDate()
For Month
(Year([Created_Date]) = Year(CurrentDate()) And Month([Created_Date]) = Month(CurrentDate()))
For Year
(Year([Created_Date]) = Year(CurrentDate()) -
BI Routnie in DTP to calculate current week from current date
Hello Team
I want to write routinue to calculate current week based on date
For eg, this week is
201410, so the routine will get 201410 based on today’s date 4 Mar 2014.
Can any1 please help
Regards,
AnkitI had written following code its giving error like
E:Field "/BI0/9AVERSION" is unknown. It is neither in one of the
specified tables nor defined by a "DATA" statement. "DATA" statement.
data: l_idx like sy-tabix.
read table l_t_range with key
fieldname = '/BI0/9AVERSION '.
l_idx = sy-tabix.
Data: Date Like scal-date.
Data: week like scal-week.
call function 'DATE_GET_WEEK'
exporting
date = sy-datum
importing
week = SOURCE_FIELDS-/BI0/9AVERSION
exceptions
date_invalid = 1
others = 2.
* Return code <> 0 means skip whole data package !!!
returncode = 0. -
How to identify which is current week by java.util.Date
below code wriiten to identify number of weeks in a given month,
i need current week in a from below code.Can any one help me?
for(int i=1;i<32;i++){
Date d = new Date(2005,11,i);
intMonDtTemp=d.getMonth();
0-sunday
1-monday
5-friday
6-saturaday
// number of weeks is based on monday's in given month
//System.out.println(intMonDtTemp+" at =month dt "+ intMonDt);
if(intMonDtTemp==intMonDt){
//System.out.println(i+" = "+ d);
//System.out.println("MONTHS EQUAL");
if(d.getDay()==1){
count= count+1;
}//end of for
if(count==5){
System.out.println(strDt+" = 5 weeks");
} else {
System.out.println(strDt+" = 4 weeks");
}//end of elseusing Calendar, not Date
import java.util.Calendar;
class Testing
public Testing()
Calendar cal = Calendar.getInstance();
int month = Calendar.OCTOBER;// months are 0-based 0-11, not 1-12
cal.set(2005,month,1);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
if(dayOfWeek > 2) dayOfWeek -= 7;
cal.add(Calendar.DATE,2 - dayOfWeek);
int mondaysInMonth = 0;
while(cal.get(Calendar.MONTH) == month)
cal.add(Calendar.DATE,7);
mondaysInMonth++;
System.out.println("Mondays in month = "+mondaysInMonth);
public static void main(String[] args){new Testing();}
} -
How can I get the Thursday of current week as a date?
Is it possible to get Thursday of the current week as a date, using a select statement?
For example, no matter what day of the week it is when I run the query, I'll get the Thursday of the current week in date form.
It should be really simple, but I'm still scratching my head on this. Thanks!SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 3) ThursdayOfCurrentWeek
Hope this helps
Thanks,
Nihar
SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 3) ThursdayOfCurrentWeek
Maybe you are looking for
-
Looking for a new toy to help your editing workflow? Try this!
I recently ditched my simple 2-button + scroll wheel mouse for a mouse on steroids: the Logitech G700. What a difference! It has 11 customizable functions that can be automatically activated depending on the program you're in! So you can have a co
-
No. of records in the table
Is any system table or a program that gives us the # of records by SAP metadata table name ?.. i have a list of table names & need to know the # of recs in all of them...so can try looking at the larger ones for analysis.. ?
-
BDC select query with addition based on all If conditions
Hi can any one send me the select query with conditions like If Itab is not initial. Endif. and if possible with valiadations messages also. IF CHECK_NUMBER of CHECK_ADVICE of the flat file = PAYR-CHECT. Then update SAP field BSEG-XREF2 . 9. When
-
How can I create a database connection to Cloudscape database in 9iJDeveloper?
How can I create a database connection to Cloudscape database in 9iJDeveloper? thanks.
-
Duplex mismatch between N7k and 5508
Hi All, I met a duplex mismatch issue in our new DC. The port configuration on the N7k and controller is the same as in other DC Only difference is version of the NxOS on the N7k. On N7k 5.2(1) works On N7k 5.2(7) i get below logs : 2013 Aug 21 22:23