Get the starting date and end date of all weeks of a given month and year
hey Guys so far I have this.. but I am having difficulty limiting it by month. I am using Oracle 11 release 1
Select year, week, next_day( to_date( '04-jan-' || year, 'dd-mon-yyyy' ) + (week-2)*7, 'sun' ) as weekStartDate,
next_day( to_date( '04-jan-' || year, 'dd-mon-yyyy' ) + (week-2)*7, 'sun' ) +6 as weekEndDate
from (Select '2012' year, rownum week from all_objects where rownum<=5)
Thanks in advance
Edited by: Aj05 on Jan 12, 2012 7:42 AM
First you need to define week starting day. If, for example it is Monday:
TRUNC(TRUNC(&dt,'YYYY') -1,'IW')is first Monday of the year. Then:
SELECT TRUNC(TRUNC(&dt,'YYYY') -1,'IW') + (LEVEL - 1) * 7 week_start_date
FROM DUAL
CONNECT BY LEVEL <= 53
/will give start dates of all weeks within &dt year. And:
WITH t AS (
SELECT TRUNC(TRUNC(&dt,'YYYY') -1,'IW') + (LEVEL - 1) * 7 week_start_date
FROM DUAL
CONNECT BY LEVEL <= 53
SELECT week_start_date,
week_start_date + 6 week_end_date
FROM t
WHERE week_start_date > TRUNC(&dt,'MM')
AND week_start_date < ADD_MONTHS(TRUNC(&dt,'MM'),1)
/will give you week start/end dates within &dt year and month. For example:
SQL> DEFINE dt="DATE '2012-03-17'"
SQL> WITH t AS (
2 SELECT TRUNC(TRUNC(&dt,'YYYY') -1,'IW') + (LEVEL - 1) * 7 week_start_date
3 FROM DUAL
4 CONNECT BY LEVEL <= 53
5 )
6 SELECT week_start_date,
7 week_start_date + 6 week_end_date
8 FROM t
9 WHERE week_start_date > TRUNC(&dt,'MM')
10 AND week_start_date < ADD_MONTHS(TRUNC(&dt,'MM'),1)
11 /
old 2: SELECT TRUNC(TRUNC(&dt,'YYYY') -1,'IW') + (LEVEL - 1) * 7 week_start_date
new 2: SELECT TRUNC(TRUNC(DATE '2012-03-17','YYYY') -1,'IW') + (LEVEL - 1) * 7 week_start_date
old 9: WHERE week_start_date > TRUNC(&dt,'MM')
new 9: WHERE week_start_date > TRUNC(DATE '2012-03-17','MM')
old 10: AND week_start_date < ADD_MONTHS(TRUNC(&dt,'MM'),1)
new 10: AND week_start_date < ADD_MONTHS(TRUNC(DATE '2012-03-17','MM'),1)
WEEK_STAR WEEK_END_
05-MAR-12 11-MAR-12
12-MAR-12 18-MAR-12
19-MAR-12 25-MAR-12
26-MAR-12 01-APR-12
SQL> SY.
Similar Messages
-
TO GET WEEKS for a given MONTH AND YEAR
Is there any FM to get the no of weeks for a given month, say 01 2005.
Can i get the week numbers say 1 2 3 4 5 for the given month and year.
Please let me know.
Happy Holidays.
Regards,
Manohar EHi Manohar,
Use FM DATE_GET_WEEK twice; first time pass first day of the month and again pass the last day of the month as a parameter. So u will be having week number(yyyyxx) for the first week of the month and week number for the last week of the month. From these two, in between week numbers u can easily fetch. I hope this will help u out.
Regards,
Kavya Shah -
How can I get the start and end of a date range?
Post Author: RobR
CA Forum: Formula
Greetings!
I have a report whose records are selected if a date field is within the date range returned by the LastFullWeek function. I want the header for that report to print the first and last dates in that range. I don't see a way to extract those dates from a date range. How do I do it?
Also, I think it would be nice to be able to walk through a date range using a for loop, something along the lines of the following:
for (thisDate in LastFullWeed)( do something;)
but I didn't see syntax like that in the help system. If I could do this, then I could get the first and last date. Is this possible?
Thank you!
RobRPost Author: SKodidine
CA Forum: Formula
If all you want is the starting date and ending date of the function LastFullWeek, then all you have to do is this:
minimum(LastFullWeek) & ' ' & maximum(LastFullWeek);
On a side note, from your post: for (thisDate in LastFullWeed) Whatcha smokin' Willis?? -
How can I get the start date and end date of a certain week?
Hello, in my java code, I can get the week ID , using
org.joda.time.base.AbstractDateTime.getWeekOfWeekyear() , for example, this week is the 16th week of this year. And I want to get the start date(date of Monday) and end date(date of Sunday) of the week. Is there any method can supply such date value??thanks1 public Date getCurrentMonday(){
2 Date monday = null;
3 Calendar rightNow = Calendar.getInstance();
4 int day = rightNow.get(Calendar.DAY_OF_WEEK);
5 int distance = 0;
6
7
8 if (day == Calendar.MONDAY)
9 monday = rightNow.getTime();
10 else
11 {
12 distance = day - Calendar.MONDAY;
13 if (distance == -1)
14 distance = 6;
15
16 monday = (Date) (rightNow.getTime());
17 monday.setTime(monday.getTime() - 1000 *60 *60 *24 *(distance));
18 }
19 return monday;
20 } -
Getting the start and end dates of the week
Hi,
I was stuck with a problem in getting the start date and end date of the week,i know the month ,week and year also,with these three values how can i get the start and end dates of a week.please help me
ThanksThere is no simple way. It has to be a math calculation.
There are several ways you can get the dates. First you have to know what day is January 1st and what day is december 31st for a particular year. Second you have to check whether the given year is a leap year or not. Based on the abvove information you should be able to find out what day is a particular date.
Hope this helps to get you started.
- Venkat Dhurjati. -
How to get starting date and ending date of the given Fiscal Period
Hi Friends,
In my Selection screen parameter, I've Fiscal year and Period , I want to get the starting date and ending date with the Fiscal period.
How to get and throught which FM.
Pls advise.
thanks®ards
Sankar.Hello Sankar,
Check the FM PERIOD_DAY_DETERMINE.
DATA :
l_periv TYPE periv,
l_blart TYPE blart,
l_fday TYPE bkpf-budat, "First day in period
l_lday TYPE bkpf-budat. "Last day in period
* Fetch the fiscal year variant from T001
SELECT SINGLE periv INTO TABLE l_periv
FROM t001
WHERE bukrs EQ p_bukrs.
* Get first day/last day
CALL FUNCTION 'PERIOD_DAY_DETERMINE'
EXPORTING
i_gjahr = p_gjahr
i_monat = p_monat
i_periv = l_periv
IMPORTING
e_fday = l_fday
e_lday = l_lday
EXCEPTIONS
error_period = 1
error_period_version = 2
firstday_not_defined = 3
period_not_defined = 4
year_invalid = 5
OTHERS = 6.
Hope this helps.
BR,
Suhas
Edited by: Suhas Saha on Jan 9, 2009 2:08 PM -
How to get the current month starting date and ending date by default ?
Hello Creators,
This is my requirement, kindly do the needful, Please dont gimme any links i've no access for other sites, gimme the right solution.
My Requirement :
Creation Date (VBAK-ERDAT) - Select Option. By default, the program should run for the current Month ie between the starting and ending date of the current month when the program is run. Today the date is 18th using sy-datum we can bring the current date by calling it in the initialization event, but the requirement is it should not give me the current date, it should only give me the month starting date and the end date. Kindly help.
Thanks in advance ...DATA: gv_datum LIKE vbak-erdat.
SELECT-OPTIONS: so_date FOR gv_datum.
INITIALIZATION.
CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
iv_date = sy-datum
IMPORTING
ev_month_begin_date = so_date-low
ev_month_end_date = so_date-high.
so_date-option = 'BT'.
APPEND so_date.
START-OF-SELECTION.
Hope this solves the issue. Don't forget to be generous
Cheers,
Sougata. -
Getting error while invoking ADF Start and End Dates
Hi,
I am new to developing ADF Application.
Into :
I am developing a search Page which has a select (drop down), startDate and endDate and a 'GO' Button
when user selects 'data from Drop Down', selects startDate and endDate and Presses 'GO' Button
Based on the Selected combination of Data i should get the Data.
Problem :
I am getting the following Error
WARNING: JBO-25058: Definition TheStartDate of type Variable not found in FastTelcoQueryTransactionDetailsVO1
What i have done / doing
Jspx -
<af:selectInputDate label="Start Date" value="#{FastTelcoTransactionBean.startDate}"></af:selectInputDate>
<af:selectInputDate label="End Date" value="#{FastTelcoTransactionBean.endDate}"></af:selectInputDate>
Bean File
I am converting the this.startDate and this.endDate (both Date format) (which i have taken startDate & endDate as Dates and Generated Getters & Setters for them ) to String format.
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(this.startDate);
map.put("_startDate", startDate);
map.put("_endDate", endDate);
VOImpl File
public void getTransStartEndDate(Number transTypeId, String startDate, String endDate)
TransactionDetailsVOImpl QueryVO = getQueryTransactionDetailsVO1();
QueryVO.setNamedWhereClauseParam("MstTransTypeId", transTypeId);
QueryVO.setNamedWhereClauseParam("TheStartDate",_startDate);
QueryVO.setNamedWhereClauseParam("TheEndDate",_endDate);
QueryVO.executeQuery();
BindVariables Used
TheStartDate - String format
TheEndDate - String format
SQL Query in VOIMPL - JDEV
SELECT DISTINCT
TransactionDetail.TRANS_TYPE_ID,
MstTransaction.TRANS_DESC,
TransactionDetail.TRANSACTION_NUMBER,
TransactionDetail.CREATOR_NAME,
TransactionDetail.CREATOR_EMAIL,
TO_CHAR(TransactionDetail.TRANS_DATE, 'MM/DD/YYYY hh:mm:ss') TRANS_DATE,
Error.ERROR_SH_MSG,
Error.ERROR_DETAIL_MSG
FROM
TRANSACTION_DETAIL TransactionDetail,
MST_TRANSACTION MstTransaction,
ERROR Error
WHERE
(TransactionDetail.TRANS_TYPE_ID = MstTransaction.TRANS_TYPE_ID)
AND (TransactionDetail.ERROR_ID = Error.ERROR_ID)
AND MstTransaction.TRANS_TYPE_ID=(:MstTransTypeId)
AND MstTransaction.IS_NOTIFICATION_REQ='Y'
AND TransactionDetail.TRANS_DATE BETWEEN (TO_DATE((:TheStartDate), 'MM/DD/YYYY')) AND (TO_DATE((:TheEndDate), 'MM/DD/YYYY'))
order by TRANS_DATE
NOTE : TheStartDate & TheEndDate are not in Attribute list of JDEV
i think i made it clear ...
anybody as a solution or Idea please provide
Thanx in advance
regards,
anvv sharmaHi,
I have started developing the code with the following SQL Query -
Query 1
SELECT DISTINCT
TransactionDetail.TRANS_TYPE_ID,
MstTransaction.TRANS_DESC,
TransactionDetail.TRANSACTION_NUMBER,
TransactionDetail.CREATOR_NAME,
TransactionDetail.CREATOR_EMAIL,
TO_CHAR(TransactionDetail.TRANS_DATE, 'MM/DD/YYYY hh:mm:ss') TRANS_DATE,
Error.ERROR_SH_MSG,
Error.ERROR_DETAIL_MSG
FROM
TRANSACTION_DETAIL TransactionDetail,
MST_TRANSACTION MstTransaction,
ERROR Error
WHERE
(TransactionDetail.TRANS_TYPE_ID = MstTransaction.TRANS_TYPE_ID)
AND (TransactionDetail.ERROR_ID = Error.ERROR_ID)
AND MstTransaction.TRANS_TYPE_ID=(:MstTransTypeId)
After that there is a change in the Requirement to add "Start Date" and "End Date" with a "Go Button" --> Clicking on this Go Button displays the Data Based on
"Drop Down" box, "Start Date" & "End Date" --> Corresponding Data is Picked From Database and Displayed....
Now, i have Updated the VO (From JDEV Design Time) with the latest Updated Query (added Start Date and End Date in the Query),
also check the Corresponding XML file is also Updated with the latest Query.
Query 2
SELECT DISTINCT
TransactionDetail.TRANS_TYPE_ID,
MstTransaction.TRANS_DESC,
TransactionDetail.TRANSACTION_NUMBER,
TransactionDetail.CREATOR_NAME,
TransactionDetail.CREATOR_EMAIL,
TransactionDetail.TRANS_DATE,
Error.ERROR_SH_MSG,
Error.ERROR_DETAIL_MSG
FROM
TRANSACTION_DETAIL TransactionDetail,
MST_TRANSACTION MstTransaction,
ERROR Error
WHERE
(TransactionDetail.TRANS_TYPE_ID = MstTransaction.TRANS_TYPE_ID)
AND (TransactionDetail.ERROR_ID = Error.ERROR_ID)
AND MstTransaction.TRANS_TYPE_ID=(:MstTransTypeId)
AND MstTransaction.IS_NOTIFICATION_REQ='Y'
AND TransactionDetail.TRANS_DATE BETWEEN (TO_DATE((:TheStartDate), 'YYYY-MM-DD')) AND (TO_DATE((:TheEndDate), 'YYYY-MM-DD')) order by TRANS_DATE
So now at Design Time i have Query 2, but Strangely at RUN Time Query 1 is Excecuting asking for "Start Date" Binding Variable NOT Found (as there is no Start Date Bind Variable in Query 1)
for this i have to re-Design the required Part...to make it work
can any body explain why it behaved like this ??
regards,
anvv sharma -
Dear all,
When I create a notification in SAP Work Manager 6.0, the notification gets created in the back-end with Start Date equal to Current Date + 1 day and End Date equal to Current Date + 3 days.
Can you advise where I can customize this behaviour, so that the Start Date is for example equal to the Current Date and End Date being 14 days in the future? Is this something that would need to be configured in Agentry Editor or within the ABAP stack?
Many thanks for your support.
Pavel
Tags edited by: Michael ApplebyHi Jason,
We went this route and identified the initial values, and tried to modify those.
No impact though, as if those values are being overwritten elsewhere (whatever value we set, no change on the backend).
Please see the attachments with screenshots of Agentry Editor.
Many thanks.
Pavel -
Getting Start and End Date of Current Year?
Hi Folks,
How do I get the start of the year and end of the year in Java ?
If I say :
Calendar cal = Calendar.getInstance();
int day = cal.get(Calendar.DATE);
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
System.out.println("Day: " + day);
System.out.println("Month: " + month);
System.out.println("Year: " + year);
I get the current day and time.What I need is the start of the current Year (Jan 2010) and the End of the Current Year (Dec 2010).
How can get the above 2 dates if I the current date is March 24th 2010 ?
Thankssabre150 wrote:
What am I missing? The start date of 2010 is 1/1/2010 and the end data is 31/12/2010 . So, as I see it, at any time the only information you need is the current year which you currently get from int year = cal.get(Calendar.YEAR);
Well, with the GregorianCalendar, anyway. ;-) -
Org.Assignment Infotype start date and End date is getting wrong.
Hi, When i create a new employee in PA40, in Org. Assignment infotype start date and end date is getting wrong. for eg. When i create an employee on 01.04.2014. In org. assignment infotype its getting like this. 01.01.2014 to 31.03.9999 and 01.04.9999 to 31.12.9999 Two date entries are creating by default.
Hi
Check in the Table - T588Z : Dynamic Actions ,is there any custom routines causing the defaulting dates functionality.
Thanks,
Sreeram -
How to find the start and ending dates of a quarter of a particular fiscal
Hi Experts,
I need a function mudule which returns starting and ending date s of a particular quarter of a particular fiscal year .
For Example: if pass 1 quarter and 2002 or 2 quarter 2002 it has to give me the star and end dates of that particular quarter na d fiscal year.
Please help me which is urgent for me.Hi Kishan thanks for reply.
But given function module the 2nd one is full but it is giving me the calender year dates but i need fiscal yea dates.
fro example: if i pass 1 st quarte and 2006 it is to give me the 1st-april to 30-jun2006.
And need this quater starting date and ending date for as per USA fiscal year calender.
If u get any idea plz let me know.
thanks.
Dashmantha. -
Hi All,
I need to get the start date and end date of a month by passing parameter like 'MAy-2011'
Result should be start date - 01-MAY-2011 and end date - 31-MAY-2011
thnxsI did the documentation drill down for you :
http://tahiti.oracle.com/
http://www.oracle.com/pls/db112/homepage?remark=tahiti
http://www.oracle.com/pls/db112/portal.all_books
http://www.oracle.com/pls/db112/portal.all_books#index-SQL
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/toc.htm
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions.htm#i1482196
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions002.htm#i88891
from here on you should be able to find a solution on yout own. -
FM to get start and end date when given month
Hi all,
can anybody help me if there a FM to get start and end date when given month like 01 for jan.
Thanks in advance
SahityaHi,
Check this Function Module
HR_JP_MONTH_BEGIN_END_DATE
here if you r giving the month u wil get the start date and the end date.
Hope this helps you.
Thanks & regards,
Y.R.Prem Kumar -
Need a Help in finding the start Date and End Date of a week
Dear All,
I need a help,
I have a date for eg,05-08-2009 (Wednesday). i need to get the week's start date and week's end date.
Week start date in my region is SATURDAY and week end date is FRIDAY .
So for my given input it should return start date as 01-08-2009 (Saturday )and end date as 07-08-2009 (Friday ).
Thanks,Got it, Solved by making a small changes to the above code .
SimpleDateFormat sf = new SimpleDateFormat("dd-MMM-yy");
Calendar cal = Calendar.getInstance(Locale.ENGLISH);
cal.set(Calendar.DATE, cal.get(GregorianCalendar.DATE));
cal.set(Calendar.MONTH, cal.get(GregorianCalendar.MONTH));
cal.set(Calendar.YEAR, cal.get(GregorianCalendar.YEAR));
if(cal.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
cal.add(Calendar.DATE, -cal.get(Calendar.DAY_OF_WEEK));
String NewEndDate = sf.format(cal.getTime());
cal.add(Calendar.DATE, -7);
String newStartDate = sf.format(cal.getTime());
System.out.println("New Start date :" +newStartDate);
System.out.println("New End Date :" +NewEndDate);Sorry, Dont want to hire any one . Just want to keep my job safe . Any way thanks for your reply .
Maybe you are looking for
-
How do I move my iTunes library from one computer to another?
Is it accessaible online or how do I do it?
-
Minor lag from GUI when resume from sleep
Hey people! I've been on archlinux for a couple of months now and I have fixed bugs here and there but something I have just noticed yesterday (it would happen before but I couldn't say when it would occur) is that after my system resume from sleep (
-
Well for about a month now my computer has been shutting down on its own. Mostly during high use like games,movies stuff like that. After I spent nearly a hour waiting to talk to a tec from gateway I was given a e-mail that didn't help at all. So by
-
hi experts i need to join mtl_system_items_b with ra_customer_trx_lines_all, and it seems very easy but problem is .. my ra_customer_trx_lines_all.inventory_item_id is null and doesnt record any code but description is there.. what is this??? is this
-
Apple/iTunes credit card and Apple Pay
I have changed my Apple/iTunes credit card and now I am unable to enter that card into Apple Pay. I don't get the prompt at the beginning of the entering process to enter the Apple Store credit card as I did before I changed the card.