Getting last-day-of-week dates within certain date range
Hi all,
I have the following Challenge:
I want to know the dates of the last day of all the weeks within a certain range of dates.
For instance if my range would be 01-jun-2002 - 31-jun-2002
then the returned days should be (lastday of the week is sunday):
. 02-jun-2002
. 09-jun-2002
. 16-jun-2002
. 23-jun-2002
. 30-jun-2002
I want to accomplish this by only using sql (no pl/sql) in a ora 8.0.x rdbms
How would I do this? (if it's possible)
Tia,
Martin
Christian's solution returns
01-JUN-02
08-JUN-02
15-JUN-02
22-JUN-02
on my system. The first day of the week is dependent on NLS settings.
SELECT MAX(realdate)
FROM (
SELECT TO_CHAR(TO_DATE('31-may-2002','dd-mon-yyyy') + ROWNUM,'IW') weekno,
TO_DATE('31-may-2002','dd-mon-yyyy') + ROWNUM realdate
FROM all_objects
WHERE rownum <= TO_DATE('30-Jun-2002','dd-mon-yyyy') - TO_DATE('01-Jun-2002','dd-mon-yyyy')
GROUP BY weeknoThe IW format model give ISO standard week numbers and a week always starts on Monday.
Similar Messages
-
Find the first and last day of week giving a certain date
Hi,
i have an application in wich the user puts a date, say today 2010-08-10 and i have to calculate first and last day of that week, in this case 2010-08-09 and 2010-08-15. How can i do this?
Many thanks in advance,
Nuno Almeidanfalmeida wrote:
i have an application in wich the user puts a date, say today 2010-08-10 and i have to calculate first and last day of that week, in this case 2010-08-09 and 2010-08-15. How can i do this?First step is being sure that you know what a 'week' is.
For example does it really start on monday? And will it always start on monday?
And what day does the 'week' end on for 2010-12-29? In some businesses it will end on 2010-12-31 (friday) -
UDF for last day of week/month
Input is a Date(For example: 2010/03/12) in String format.
I need to extract the last day of that week and return it as a string output.
For example if input is 2010/03/12 and thatu2019s a Thursday my output should be 2010/03/14 i.e Saturdayu2019s date.
Similarly I need to extract last day of month too.
Thanks in advance
Soumen...Hi,
I did not develop this one... but just use "search" button on roseindia and you will have the answer (I think):
[http://www.roseindia.net/java/beginners/DayOfYearToDayOfWeek.shtml|http://www.roseindia.net/java/beginners/DayOfYearToDayOfWeek.shtml]
and do not forget that Google is your friend...
do a research with : Java last day of week, and you have plenty of examples.
Thanks.
P.S: Say us when you will solved your problem. -
hi ,
is there an existing date funtion to get last day of the month ?
pls advise
else
i'll try to add_month + 1 to current month and format to the first day and minus 1 day from that new month
tks & rdgslast_day function
<br>
jeneesh -
How to get Last Day of a Previous Month
Hi all,
I need to get Last Day of the Previous Month. I am able to get Current Month Last Day using Calendar.getActualMaximum(Calendar.DATE)
But I need previous Month's Last Day.
Thanks
Vamshi.Thanks all....
I have been trying the same and could get it.....
here is the code for that....
SimpleDateFormat simpleDate = new SimpleDateFormat("MM/dd/yyyy");
Calendar calendar = Calendar.getInstance();
month = calendar.get(Calendar.MONTH);
//year = calendar.get(Calendar.YEAR);
calendar.set(Calendar.MONTH, month-1);
calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
//lastDayOfMonth = calendar.getActualMaximum(Calendar.DATE);
System.out.Println("Previous Month End Date is :: " + simpleDate.format(calendar.getTime()));
this works....
thanks for ur replys.... -
Function Modules to get First day of week, month, Year
Can anyone name the Function Modules for getting First day of week, month ,year.
to get first day of week use this function; WEEK_GET_FIRST_DAY
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
WEEK = '201107'
IMPORTING
DATE = l_date
EXCEPTIONS
WEEK_INVALID = 1
OTHERS = 2.
with DATE_COMPUTE_DAY function you can get date number in week.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = workdate
IMPORTING
DAY = day_of_week_num
EXCEPTIONS
OTHERS = 8.
CASE day_of_week_num.
WHEN 1.
hold_day_of_week = 'Monday'.
WHEN 2.
hold_day_of_week = 'Tuesday'.
WHEN 3.
hold_day_of_week = 'Wednesday'.
WHEN 4.
hold_day_of_week = 'Thursday'.
WHEN 5.
hold_day_of_week = 'Friday'.
WHEN 6.
hold_day_of_week = 'Saturday'.
WHEN 7.
hold_day_of_week = 'Sunday'.
WHEN OTHERS.
hold_day_of_week = 'invalid'.
ENDCASE. -
Adding reminders to my calendar items is no longer an option after the software upgrade. I also can't get to day and week view, only month view. What's a possible solution? I'm using Andriod version 4.4.2 with kernal 3.4.0.
@MaloneTP
Thanks for keeping me updated! Do you see the screen options displayed in the following link: http://bit.ly/T2koBL for changing the calendar view options in Kies Air? Also, let me know if you're able to add a Reminder by following these steps: http://bit.ly/T2l9dY. Keep me posted. Thanks!
AnthonyTa_VZW
Follow us on Twitter @VZWSupport -
How to capture the data within the given range of maximum and minimum values ? from csv files
My requirement,
1. Here, the user will provide the range like maximum and minimum values, based on this range, the VI should capture the data within the given range. ( from CSV file as attached )
2. Then VI should calcluate the average value for captured data and export it to excel.
This is my requirement can anyone help me on this.
Many thanks in advance
rc_cks
Attachments:
sample_short.csv 2439 KBHi,
Thanks for remnding me. I forgt to attach the VI,
Here I am attaching the VI, what I tried.
From attached CSV file, I have to find an average value for columns B,C,D,E,F,G,H,I and AJ, AK. ( data range will be defined by user ), focused only on these columns
Here, the scope is to calculate an average value for given data range by user as MAX and MIN data.
FYI: I tried manually for two instance i.e column H & I. As per H column one steady state values from 7500 to 10500 and similarly in I column 7875 to 10050. So, I gave these as a limit to capture and calculate the average value. But unfortunaltely, requirement has been modified as per below requirements.
More Info on requirement:
--> The user will define the range of data by giving some MAXIMUM and MINIMUM values(for above mentioned columns induvidually), then VI should capture that data range and it has to caculate the average value for that range of data. This is the task I have to complete.
--> I am stuck in creating a logic for data capturing for given range of MAX and MIN value from user,
Can anyone help me on this.
If my explanation is not clear, Please let me know.
Many thanks, help mw
rc
Attachments:
VI_rc.vi 25 KB
sample.zip 4166 KB -
Getting first and last day of week
Dear all .
Is there any funcion module which gives first and last day of the current week .
Eg . todays day is 15.11.2006
start date of week : 13.11.2006
end date of week : 19.11.2006
in the same way I want how many days are there in month .
Eg : for Nov month :
30 days .
for dec month 31 days .
Thank you in advanceUse FM GET_WEEK_INFO_BASED_ON_DATE
Import parameters Value
DATE 15.11.2006
Export parameters Value
WEEK 200646
MONDAY 13.11.2006
SUNDAY 19.11.2006
Use FM HR_E_NUM_OF_DAYS_OF_MONTH
Import parameters Value
P_FECHA 15.11.2006
Export parameters Value
NUMBER_OF_DAYS 30
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers -
How to get the first and the last record of every month within a time range in sql
I am trying to get the first record and the last record of each and every month in a given date range using sql. I have a sample code
where i have just selected everything within the date range now i have to extract the first and the last records of each and every month.
SELECT PurOrderNum,
OrderDate
FROM Purchasing.PurOrder
WHERE OrderDate >= '2013-02-28'
AND OrderDate <= '2014-12-29'SELECT PurOrderNum,
OrderDate
FROM
SELECT PurOrderNum,
OrderDate,
MAX(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MaxDate,
MIN(OrderDate) OVER (PARTITION BY DATEDIFF(mm,0,OrderDate)) AS MinDate
FROM Purchasing.PurOrder
WHERE OrderDate >= '2013-02-28'
AND OrderDate <= '2014-12-29'
)t
WHERE OrderDate = MaxDate
OR OrderDate = MinDate
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
First and last day of current year as a date object
Howdy...
can someone please help me out... i need a fast way to get the first day of the current year as a date object and the last day of the current year as a date object...
big thanks for any sample code...import java.util.Calendar;
// snip
Calendar firstDayOfYear = Calendar.getInstance(); // will initialize it with today
firstDayOfYear.set(Calendar.DAY_OF_MONTH, 1);
firstDayOfYear.set(Calendar.MONTH, Calendar.JANUARY);
Calendar lastDayOfYear = Calendar.getInstance(); // will initialize it with today
lastDayOfYear.set(Calendar.DAY_OF_MONTH, 31);
lastDayOfYear.set(Calendar.MONTH, Calendar.DECEMBER);Rommie. -
Dynamic variable to get last day of month
Hi all,
I have created one report where in YTD is calculated based on stsyem date. NOw in this report the cal month is in row thus displaying data month wise. But i need one key figure which giving the last day vaue of every month that are displayed in YTD i.e this is based on cal day. Thus the report layout is as follows:
if report is run in mar 2007 then it should display:
For calmonth key figure due amount
For Jan 07 this should show due value on last day of jan 07 (i.e 31st jan 07)
for Feb 07 this should show due value on last day of feb 07 (i.e 28th feb 07)
for Mar 07 this should show due value on last day of mar 07 (i.e 31st mar 07)
customer exit variable can give me only one value at a time. How can I make it dynamic to take last day value of every month as per cal month. Could anybody explain me if worked on any such issue.
If there is some how to paper kindly mail me at my email Id : [email protected]
thanks in advance
Regards,
WrushaliHi,
U can use FM : SLS_MISC_GET_LAST_DAY_OF_MONTH to get the last day of the month by passing the date/current date.
Thanks,
Debasish -
FM for getting all days of week
Hi,
When I enter todays date FM should bring up all dates in a week.
Eg: today if user enters 02/04/2009
It should give me values 3/29 , 3/30 , 3/31, 01/04,02/04 etc..
Do we have any FM for this?
Rgds
PraveenHi Praveen
In the below mentioned funtion modules you can get almost all type of days & weeks calculations...
For your requirement just do this
"To calculate week Start & End date
CALL FUNCTION 'HRWPC_BL_DATES_WEEK_INTERVAL'
EXPORTING
DATUM = SY-DATUM " Current date (ITAB DATE)
WEEK_PST = '0'
WEEK_FTR = '0'
IMPORTING
BEGDA = STR_WEEK_DATE " Week start date
ENDDA = END_WEEK_DATE. " Week end date
then
day1 = STR_WEEK_DATE
day2 = day1 + 1.
day3 = day2 + 1.
till day7...
"To calculate week no for particular date
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = SY-DATUM " any date
IMPORTING
WEEK = WEEK_NO ." Week no for particular date
"To calculate week Start & End date
CALL FUNCTION 'HRWPC_BL_DATES_WEEK_INTERVAL'
EXPORTING
DATUM = SY-DATUM " Current date (ITAB DATE)
WEEK_PST = '0'
WEEK_FTR = '0'
IMPORTING
BEGDA = STR_WEEK_DATE " Week start date
ENDDA = END_WEEK_DATE. " Week end date
"To calculate Months ending date
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = SY-DATUM " Any date
IMPORTING
E_DATE = END_MONTH_DATE. " Month's ending date
"to calculate particular day No for any give date.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = SY-DATUM " any date
IMPORTING
DAY = DAYNO1. " particular day no.
"To calculate particular day name with the day no
CALL FUNCTION 'BKK_GET_DAY_OF_WEEK'
EXPORTING
I_DAY = DAYNO " week day no.
IMPORTING
E_WDAY = CURRENT_DAY_NAME. " Week day name for the week day no.
" to Calculate the next week
CALL FUNCTION 'NEXT_WEEK'
EXPORTING
CURRENT_WEEK = WEEK_NO "Current week,
IMPORTING
NEXT_WEEK = WEEK_NO. " Next week
" to calculating starting date of the week
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
WEEK = WEEK_NO "week No
IMPORTING
DATE = STR_WEEK_DATE. " Starting date of the particular week
"To Calculate particular day No for any given date
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
DATUM = STR_WEEK_DATE " Any date
IMPORTING
WOTNR = DAY. " Day no for a giveN date
Hopw this solves your Problem
Thanks & regards,
Dileep .C -
Customer Exit to get last day of month from Year/month
Hi Experts,
I need to create a customer exit to get the last day of month from Cal Year month input variable.
Examples
1)
User input period: 12.2008
I need from the customer exit: 31.12.2008
2)
User input period: 02.2009
I need from the customer exit: 28.02.2009
Can someone help me with the ABAP code to achieve this with a customer exit?
Help will be appreciated.Hi,
Please use the following code,
Second one is the suitable solution for you, I can understand that, if it leafe year then you have the problem so use the secon one.
First one is using Period i.e. 010.2008 (December 2008).
Secodn one is based on Date/Month.
Note: Insted of SY-DATUm, you give your variable name
*******To get the Last day of the Fy Period entered by User in ZFYP***
WHEN 'ZLDAY_FI'.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZFYP'.
zbdatj = loc_var_range-low+0(4).
zbuper = loc_var_range-low+4(3).
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr = zbdatj
i_periv = 'V3'
i_poper = zbuper
IMPORTING
e_date = zzdate.
CLEAR: l_s_range.
l_s_range-low = zzdate.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
Note: in the below code I given SY-DATUM, so you change to your Month Variable like using
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'XXXX'.
** Last Day of Current Calendar month
zzdate = sy-datum.
CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
EXPORTING
iv_date = zzdate
IMPORTING
ev_days = znum.
CLEAR: l_s_range.
l_s_range-low+6(2) = znum.
l_s_range-low+0(4) = sy-datum+0(4).
l_s_range-low+4(2) = sy-datum+4(2).
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
Thanks
Reddy
Edited by: Surendra Reddy on Jan 27, 2009 2:47 PM
Edited by: Surendra Reddy on Jan 28, 2009 6:12 AM -
How to get last day of the year
Hi All ,
Thanks in advance ...
How will I get the last day of the year as I am passing date at run time .
I can manage to get first day of year by
SELECT TRUNC(SYSDATE,'YEAR') AS FDAY_YEAR
from dual
Thanks in advance
Regards
Sachin1* select ADD_MONTHS(trunc(sysdate,'yyyy'),12)-1 dd from dual
SQL> /
DD
31-DEC-2010
Maybe you are looking for
-
Satellite P300D-10v - Question about warranty
HI EVERYBODY I have these overheating problems with my laptop Satellite P300D-10v. I did everything I could do to fix it without any success.. I get the latest update of the bios from Toshiba. I cleaned my lap with compressed air first and then disas
-
Problems with track pad and osx installation disc on macbok.
Okay so I am having two separate problems with my macbook. First, the track pad, or the button beneath it, is pretty much completely out of commission. When I try and use it, the computer acts as if I am holding down the button all the time. Example,
-
Delivery related problem in STO
Dear All, While doing STO (Stock Transfer Order) we have raised 4 Purchase Orders (POs) among which it is observed later on that in one of the PO for one of the material the valuation type is not extended in the recipient plant.Still 4 deliveries and
-
Loss of functionality in JD3?
In a JD3 applet, the ComboBoxControl** will update a row (such as empno = 100) in the EMP table that already has a JOB value (e.g., 'Clerk'). However, the ComboBoxControl will NOT update a row (such as empno = 125) in the EMP table that DOES NOT alre
-
Iweb Blog ftp or mobile me?
I have just designed a website in iweb that I ftp through godaddy. Took a while to make that decision, but at least I have complete design control! I am doing pretty well and now at the search rankings stage and realize that iweb isn't great at that.