Get the date of a particular week day from given date
I have a given date.
from that date i want to get the date of sunday of that week
wat is the best possible way to do the same.
for eg:
if i am given 03/11/2007 which is a saturday
i want to get 27/10/2007 which is the sunday which falls in the same week as of 03/11/2007
can anybody please help.
hi,
Here I am posting code for your requirement.
Here I am hard coding the date value.
import java.util.*;
public class DateTest{
public static void main(String ar[]){
Calendar calendar =new GregorianCalendar(2007,7,4);
System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
calendar.set(2007,7,4-calendar.get(Calendar.DAY_OF_WEEK)+1);
System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
}
Similar Messages
-
Releasing the waves on a particular week day based on customer
Hi,
We have a requirement to release the waves on a particular week day based on the customer, like for one customer we have to release the wave on Monday and another one on Wednesday. Is there a way to achieve this functionality. Your help is greatly appreciated.
Regards,
SobhanHi Juergen,
Thanks for your reply. I have 20 different customers for whom have to release the wave separately on a different day and time. Do you think creating the calendar is the only option?
Regards,
Sobhan -
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. -
How to get the date for the last day of a week?
Is there a easy way to get the date for the last day of week?
eg a week starts on monday and end on sunday
January 11, 2005 is the start date for the week
January 17, 2005 is the end date for the week
or
say
February 26, 2003 is the start date for the week
March 5, 2003 is the end date for the week
I just need a simple way of figuring that out....
I figured out how to get the start date for the week but just can't get the latter..
formatting of the date is not of a concern.. that I know how to do
thanks in advanceHow about something like the following?
Calendar someDay = new GregorianCalendar(2005,0,11);//2005 Jan, 11
//Note above that January is 0, not 1, as counting starts from 0.
someDay.add(Calendar.DAY_OF_MONTH,6); //add 6 days
java.util.Date lastDayOfWeek = someDay.getTime();
//If someDay was the start of a week, lastDayOfWeek should now be
//the last day of that week.
System.out.println(lastDayOfWeek.toString() ); -
Can I get the date to display along with the day and time
can I get the date displayed with the day of week and time?
Hi Mary, you can, but what version of OSX are you running on what Mac?
See if this helps for starters...
http://paulstamatiou.com/how-to-display-date-in-os-x-menu-bar -
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 -
Hi All,
I have a simple query which is below:-
Declare @reportdate date
set @reportdate= (DATEADD(dd,-5,getdate()))
select * from dbo.Table
where date IN (@reportdate)
I need this query to pull the data for the last 3rd business day .So lets say today is monday then i need the data for last week wednesday which is 3 business days back from monday, if today is a tuesday it would be for last thursday ( as 3 business days for
tuesday would be thursday). But if today is wednesday then i need to be last 3rd business day which is last friday and i also need to get the data for saturday and sunday.
Can someone please help me how cani change my filter to do this?
Please let me know if i am still unclear.
ThanksHi SqlDev12,
Based on my understanding on your requirement, you can reference the below sample.
CREATE TABLE BusinessTable
Bdate DATE,
Wd VARCHAR(10)
;WITH Cte(DT,WD) AS
SELECT CAST('20150401' AS DATE),DATENAME(WEEKDAY,CAST('20150401' AS DATE))
UNION ALL
SELECT DATEADD(DAY,1,DT),DATENAME(WEEKDAY,DATEADD(DAY,1,DT)) FROM Cte
WHERE DT<GETDATE()
INSERT INTO BusinessTable SELECT * FROM Cte
SELECT * FROM BusinessTable
SET DATEFIRST 7 -- Set Sunday as the first day of a week
DECLARE @givenDay DATE ='20150415' --Wednesday
SELECT * FROM BusinessTable
WHERE Bdate BETWEEN
--For Monday and Sunday, select last wednesday
(CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
--For Tuesday and Wednesday, last week's Thursday and Friday
WHEN DATEPART(WEEKDAY,@givenDay) IN(3,4) THEN DATEADD(DAY,-5,@givenDay)
--For Thursday and Friday, current week's Monday and Tuesday
WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
--For Saturday, current week's Wednesday
ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
AND
(CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
WHEN DATEPART(WEEKDAY,@givenDay) IN(3) THEN DATEADD(DAY,-5,@givenDay)
WHEN DATEPART(WEEKDAY,@givenDay) IN(4) THEN DATEADD(DAY,-3,@givenDay)
WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
DROP TABLE BusinessTable
If you have any feedback on our support, you can click
here.
Eric Zhang
TechNet Community Support -
Logic to build report to get the stock on a particular date
Dear Guru's,
We are trying to build a report for getting the stock on a particular date. It is not possible to copy MB5B that option is ruled out. We have also tried to get the data from MBEWH but that is also not helping as the table is not updated for all the periods.
Please advice
Thanks,
SamDear Sameer,
You can copy MB5B report and can modify as per your reuirement.
If you want get stock a paticular date.It is hard to get, why because you have to fetch all the Material documents
and you have to use MBEW table to get the current date stock and you have to do add/subtract from calculated stock.
Due to this there will performance issues also.
So try to copy MB5B and change as per your requirement.
regards
Subhash -
How to get the Date in a particular format?
Hi,
How to get the Date in the below format? I will be passing the year in my method..
2/10/2003 9:46:52 PM
D/M/YYYY H:M:S A
public Date getDate (String year) {
Here i want to get the Date in this format
2/10/<Passed Year> 9:46:52 PM
ThanksThis is my code
public static Date getCalendar(Calendar calendar,int getYear) {
String formatted_date="";
int year = getYear;
int month = calendar.get(Calendar.MONTH+1);
int day = calendar.get(Calendar.DATE);
int hour = calendar.get(Calendar.HOUR);
int min = calendar.get(Calendar.MINUTE);
int sec = calendar.get(Calendar.SECOND);
int am_pm =calendar.get(Calendar.AM_PM);
formatted_date = month+"/"+day+"/"+year+" "+hour+":"+min+":"+sec+" PM";
System.out.println("formatted_date is "+formatted_date);
o/p : formatted_date is 1/4/2006 1:44:21 PM
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
// DateFormat dateFormat =DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
Date passdate = new Date();
try {
passdate = dateFormat.parse(formatted_date);
} catch (ParseException e) {
System.out.println("Invalid Date Parser Exception "+e.getLocalizedMessage()+"DateFormat is "+dateFormat);
System.out.println("The Date inside the function is "+passdate+"and the year passed is "+year);
o/p : The Date inside the function is Sat Apr 01 00:00:00 IST 2006and the year passed is 2006
return passdate;
Expected O/P is 3/1/2006 1:44:12 PM
} -
How to get the date of Friday for the given week
HI,
I have a requirement to get the date of Friday for the given week.
Eg: I have an input of 200722 (Yearweek), From this I need to get the Date of the friday for this week 22 of Year 2007.
Plz let me know how to get this..
Thanks in advance..
Sridhar.Hi,
Thanks for your reply...
I have implemented your logic but not getting exact output as required.
Suppose, If i give the input as 200720, I am getting an output as 18 (friday of week 20 of year 2007), but i need to get an output of 18.05.2007
Plz let me know how to do thdi.
Thanks in advance.. -
I have updated my mac from snow leopard to mountain lion 3 days back. I had some important data in my library folder and it got overwritten. Is there any way i can get the data back from my snow leopard library folder?
I tried mackeeper to recover files but it could not. Any other way any one has tried to recover a system library folder after OS upgrade?No, it doesn't store a clone. You would have needed to make one with either SuperDuper or CarbonCopy Cloner.
If the files were in your ~/Library folder then they may still be there. As I said, you can access it by
going to your Finder "Go" menu hold the option key to choose "Library". I wouldn't think an upgrade would overwrite anything in ~/Library.
If you have a Time Machine backup you may also be able to use that to retrieve them. -
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 -
Getting the date along with day and time on top right of sreen
I know this sounds stupid, but I can' get the date to show up on the top right hand corner of screen to the left of the speaker icon. With tiger I had a facsimile calendar with the date and time of day on the bottom of my screen next to dock. Very nice. That disappeared with intro of Leopard ... any advice will be welcome. Steve in Phoenix
This is the standard function and features of the menubar clock in OS X 10.3 thru 10.5.
You will need to find a third party application to do what you wish. -
How to get the data of a particular attribute
Hi,
I want to display some of the names in a table .
(condition is given in the SELECT statement)
please tell me what to write in the while loop for getting the data . I used
while (rs.next()!=null){
String i =rs.getString("name");
it`s not compiling.replace this line with
while (rs.next()!=null){
with
while (rs.next()){ -
Define a join in Webi Report which gets the data from two Excel files
Hello,
I have the following excel records as a source for my Webi Report:
Excel 1
Excel 2
Date
Month
Month
Year
Year
Total Number of Days
in Month
No. Of Exec
Functional
Area
Now I need to show No. of executions/Total Number of Days in Month per functional area (Where Month of Excel 1 is Month of Excel 2).
For this:
I have Merged, Month of Excel 1 and Month of Excel 2, Year of Excel 1 and Year of Excel 2.
Created a variable vNoofExec , No. of Exec/Total Number of Days in Month.
Created a graph, with Merged Month, Merged Year, vNoofExec with Region Color on 'Functional Area'.
But, it doesn't work.
If I replace vNoofExec with No. Of Exec I get the data, but not with vNoofExec.
Any Idea how we can get a solution for this?
Best regards,
Praveen.Hi Amit,
Thank you for your reply.
I tried putting them in a table to see if I am getting the value for vNoofExec but, no, I am not getting. Here is the dummy data for both the excels:
1. Excel 1:
Year
Month
Week
Date
No. Of Exec
Functional Area
2013
1
30
26
1
FA1
2013
2
21
20
12
FA2
2013
3
21
21
1
FA3
2013
4
21
22
5
FA4
2013
5
21
23
2
FA5
2. Excel 2:
Year
Month
TotalDays
2013
1
31
2013
2
28
2013
3
31
2013
4
30
2013
5
31
What I found is, if I create a measure like, [No. of Exec] where ([Functional Area]="FA1") and use this measure in the graph I am able to see the data even if I use Total Days in the Graph, but, I cannot create multiple measures like this because for me number of Functional Areas will be changing always.
Maybe you are looking for
-
Outbound delivery creation in case of stock transfer scheduling agreement.
Dear All, We are creating the Scheduling Agreement for the stock transfer between the 2 plants . and for the stock transfer we are following the outbound delivery route (641 movement type) Issue is as below:- suppose in the scheduling Agreement I hav
-
Call of constant function in where clause
Hi there, I want to execute the following query select a_field from a_table where another_field = a_func('10') where a_func is a stored function and returns a value dependent on its argument. Same argument returns same result. How to see, the argumen
-
I have been provided with a report that requires the parameter field to be populated with the word u2018Weeku2019 and followed by the week number i.e. Week 02 I have an automated system for exporting reports via email, and I can set the parameters to
-
Bex Query is working fine in Bex Analyzer but in Webi 4.0 its not.
Hi guys, I am using Bex Query as a datasrouce for a Interactive Analysis 4.o. but its giving me the following error below: Note: i can use other Bex Queries just fine in interactive analysis, and this problomatic query is working fine in Bex Analyzer
-
Using EDI/IDOC transfer data between two systems
Hello, I would like to transfer invoice data from one R/3 system to another R/3 system using XI. I am thinking that it should be possible using Output type determination of the TCode MIRO. Is it possible to achieve this by creating 1. Output type