Grouping Via Week Ending Date
Hi All,
I have transaction line data for each day for our customer and i would like to group via Week Ending date. Our week runs from Sunday to Saturday.
If i Add the transaction date to the group expert it allows me to group via week(perfect) but does it via week commencing. I see you can group via formula, does any one know how you can get the grouping via Week Ending.
thanks for any help and advise.
mike
Try using this formula...
DateAdd("ww", DateDiff("ww", #1/6/1900#, {TableName.DateField}), #1/6/1900#)
This formula will calculate the "Following Saturday" for any given date. If the date supplied is a Saturday, it will return that same date.
So...
11/2/2010 > 11/6/2010
11/13/2010 > 11/13/2010
11/14/2010 > 11/20/2010
HTH,
Jason
Similar Messages
-
Group by week between date range
Hi,
i'm having a table for documents. The documents are received from diffeent dates. I've to calculate number of documents received on weekly basis.
I need an sql to count the number of documents between two given dates grouping by weekly.
My week starts on Sunday and ends with Saturday.
I've tried group by with to_char(documentdate,'IW') , but this will take Monday to Sunday as a week & the incomlete weeks i'm not able to calculate. ie : in the below output the date range 1/28/2007 - 1/31/2007 is not a complete week . ( ie saturday to wednesday)
I need out put should be like this for Date Range: 12/31/2006 to 1/31/2007
week count of documents
12/31/2006 - 1/6/2007 10
1/7/2007 - 1/13/2007 40
1/14/2007 - 1/20/2007 30
1/21/2007 - 1/27/2007 20
1/28/2007 - 1/31/2007 10
Please help me to get this.....
(columns in documents table is documentid and documentdate)your're very close with IW. you just need to shift the data to get it to fall within the correct range. btw, you don't need julian dates. it's overkill
trunc(date+1,'IW') will push the date into the correct week range (IW will put sunday one week earlier than you want, so push it ahead a day before truncating).
then subtract 1 day from the result to get it to display with sunday's date instead of monday
trunc(mydate+1, 'IW')-1
and the week end date is simply trunc(mydate+1, 'IW')_5
select mydate, to_char(mydate,'Dy') dy,
trunc(mydate+1,'IW')-1 wk_Start,
trunc(mydate+1,'IW')+5 wk_end
from (select sysdate-rownum mydate from dual connect by level < 20)
order by 1 -
Get week ending date from Year and Week Number
I would like to display the week ending date in a Report.
My dataset query has grouped the results by year and week number, so I am trying to construct the week ending date from year and week number.Week end date can be got as below
=DateAdd(DateInterval.WeekOfYear,CInt(Fields!WeekNumber.Value) -1,DateAdd(DateInterval.Year,(Cint(Fields!Year.Value) - 1900),CInt("12/31/1899")))
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Week Ending Dates Logic....
Hi All,
I need to do a Count(measure) group by a week .
Week is defined as should contain the "end of the each week" values.
I tried:
to_char(trunc(to_date(INPUT_DT,'YYYYMMDD'),'W')+7,'MM/DD/YYYY')
but i get the wrong week ending dates? Any ideas?
I get the values as:
2/05/08,
2/08/08,
2/15/08,
2/22/08,
2/29/08,
3/07/08,
3/08/08,
3/15/08,
3/22/08.
Message was edited by:
user521009I need to do a Count(measure) group by a week .
Week is defined as should contain the "end of the
each week" values.
Maybe this could help:
test@ORA10G>
test@ORA10G> -- this query displays the end date of each week in the current year
test@ORA10G>
test@ORA10G> select
2 to_char(trunc(sysdate,'yyyy')+level-1,'ww') as week_number,
3 max(trunc(sysdate,'yyyy')+level-1) as end_date
4 from dual
5 connect by level <= trunc(add_months(sysdate,12),'yyyy') - trunc(sysdate,'yyyy')
6 group by to_char(trunc(sysdate,'yyyy')+level-1,'ww')
7 order by to_number(to_char(trunc(sysdate,'yyyy')+level-1,'ww'))
8 /
WE END_DATE
01 07-JAN-08
02 14-JAN-08
03 21-JAN-08
04 28-JAN-08
05 04-FEB-08
06 11-FEB-08
07 18-FEB-08
08 25-FEB-08
09 03-MAR-08
10 10-MAR-08
11 17-MAR-08
12 24-MAR-08
13 31-MAR-08
14 07-APR-08
15 14-APR-08
16 21-APR-08
17 28-APR-08
18 05-MAY-08
19 12-MAY-08
20 19-MAY-08
21 26-MAY-08
22 02-JUN-08
23 09-JUN-08
24 16-JUN-08
25 23-JUN-08
26 30-JUN-08
27 07-JUL-08
28 14-JUL-08
29 21-JUL-08
30 28-JUL-08
31 04-AUG-08
32 11-AUG-08
33 18-AUG-08
34 25-AUG-08
35 01-SEP-08
36 08-SEP-08
37 15-SEP-08
38 22-SEP-08
39 29-SEP-08
40 06-OCT-08
41 13-OCT-08
42 20-OCT-08
43 27-OCT-08
44 03-NOV-08
45 10-NOV-08
46 17-NOV-08
47 24-NOV-08
48 01-DEC-08
49 08-DEC-08
50 15-DEC-08
51 22-DEC-08
52 29-DEC-08
53 31-DEC-08
53 rows selected.
test@ORA10G>
test@ORA10G>pratz -
PDF form Week ending date auto populate
i have a pdf form i am doing. it has a java script to make the week ending date populate other fields and minus a day.
if (WEEK_ENDING.rawValue == null)
{$.rawValue = "";}
else
{Num2Date(Date2Num(WEEK_ENDING.formattedValue, DateFmt(1)) - 0, DateFmt(1));}
endif
this works for the first date, but when i change it to
if (WEEK_ENDING.rawValue == null)
{$.rawValue = "";}
else
{Num2Date(Date2Num(WEEK_ENDING.formattedValue, DateFmt(1)) - 1, DateFmt(1));}
endif
it does not work. any idea what i am doing wrong?
TinaHi Tina,
Well at first look, seems like you mixed FormCalc and JavaScript together...
Num2Date and Date2Num can only be used in FormCalc, and you can't use these { } in FormCalc
You should be using the if (), then, else, elseif, endif for FormCalc
if (WEEK_ENDING.rawValue == null) then
$.rawValue = ""
else
Num2Date(Date2Num(WEEK_ENDING.formattedValue, DateFmt(1)) - 1, DateFmt(1))
or
Num2Date(Date2Num(DateTimeField1.rawValue, "YYYY-MM-DD") + 1, DateFmt(1))
endif -
Week end Date Query...
Hi
I want Week end date for the following Condition.
1.If month start date from sunday or monday mean week end should be Current Sat date other wise i want next saturday as first week end date.
For Eg.. AUG 2006
O/P should be
12-aug-2006
19-aug-2006
26-aug-2006
31-aug-2006
2.If Months Starts from sun or monday mean i don't want last sat in the list
For Eg.. JAN 2006
07-jan-2006
14-jan-2006
21-jan-2006
31-jan-2006
Hlp me
Regards
ManikandanHi jeneesh,
Thanks for giving the query ... For the Below Same query i need
1.If the first week of the month is Sunday Or Monday then week1 ends on the first saturday else week1 ends on the second saturday of the month.
2. Week 2 ends on the next Saturday ( next to the one identified above)
3. Week3 ends on the next Saturday ( next to the one indentified in step 2)
4. Week4 ends on the last day of the Month.
For Eg of JAN-2006, i don't want to display last sat.. insteed of i want to display last day of the month ,
SELECT NEXT_DAY(TO_DATE('JAN-2006','mon-yyyy')+5+(N-1)*7,'SATURDAY') col1
FROM (SELECT ROWNUM N
FROM DUAL
CONNECT BY LEVEL <= 4)
WHERE NEXT_DAY(TO_DATE('JAN-2006','mon-yyyy')+5+(N-1)*7,'SATURDAY') <= LAST_DAY(TO_DATE('JAN-2006','mon-yyyy')) -
Hi -
I need to calculate weekending in OBIEE Answers.
The week will start with Sunday and end with Saturday. The week ending date for this week should be Friday of this week.
for example :
7th October 2012 (Sunday) - 13th October 2012(Saturday) Week Ending date should be (12th October 2012)
Thanks!user8021111 wrote:
Hi -
Sorry.. this doesn't solved my issue..
for example in column A I have dates like
Column A Column B(Should be populate the week Ending Date)
30 SEP 2012 05 OCT 2012
01 OCT 2012 05 OCT 2012
02 OCT 2012 05 OCT 2012
03 OCT 2012 05 OCT 2012
04 OCT 2012 05 OCT 2012
05 OCT 2012 05 OCT 2012
06 OCT 2012 05 OCT 2012
07 OCT 2012 12 OCT 2012
08OCT2012 12 OCT 2012
09 OCT 2012 12 OCT 2012
10 OCT 2012 12 OCT 2012
11 OCT 2012 12 OCT 2012
12 OCT 2012 12 OCT 2012
13 OCT 2012 12 OCT 2012
The week ending date should be considered as friday of the week..the week will start from sat and end with sund.. this all should fall under friday of that week..
Sorry for the inconvenience caused... Thanks again.
Thanks,Next time give the examples the first time, it'll be easier to see. Here is the formula for column B:
TIMESTAMPADD(SQL_TSI_DAY, DAYOFWEEK(column_A)*-1+6, column_A) -
Week ending date after 365 days in sql
Hi Experts,
I need to find the week ending date after 365 days of the given week start date .
Example : Week start date : 23-Jan -2011 (Sunday)
Desired week end date : 28-Jan-2012 (Saturday)
How to achive this through sql ?
Thanks .Hi,
Check below this may help you, adjust "(t.day_num+1)" as per your requirment.
with t as
(select decode(to_char(trunc(sysdate + 365), 'dy'),'mon',1,
'tue',2,
'wed',3,
'thu',4,
'fri',5,
'sat',6,
'sun',7) day_num
from dual
select to_char(trunc(sysdate + 365)+ (7-(t.day_num+1)),'dd dy-mm-yyyy')
from t ; -
Week End Date calculates dates in table issues
Greetings All,
I'm working on a LiveCycle Designer ES4 document that has a Week Ending Date MM-DD-YYYY (which need to always be a Saturday) selected in a subform.
I need this Week End Date to then calculate and display the selected Saturday and the previous days in a seperate subform with a table. The days need to display in seperate columns below the header.
This is what I have so far:
TopmostSubform.Page1.Requestor.WeekEndDate::exit - (FormCalc, client)
var endDate = Date2Num($,"MM-DD-YYYY")
var dayOfWeek = Num2Date(endDate, "E")
if (dayOfWeek <> 7) then
xfa.host.messageBox("Ending date must be a Saturday")
$ = null
xfa.host.setFocus("$")
endif
Page1.#subform[1].InputTable.Row1[0].Date7 = Num2Date(endDate - 0, "DD")
Page1.#subform[1].InputTable.Row1[0].Date6 = Num2Date(endDate - 1, "DD")
Page1.#subform[1].InputTable.Row1[0].Date5 = Num2Date(endDate - 2, "DD")
Page1.#subform[1].InputTable.Row1[0].Date4 = Num2Date(endDate - 3, "DD")
Page1.#subform[1].InputTable.Row1[0].Date3 = Num2Date(endDate - 4, "DD")
Page1.#subform[1].InputTable.Row1[0].Date2 = Num2Date(endDate - 5, "DD")
Page1.#subform[1].InputTable.Row1[0].Date1 = Num2Date(endDate - 6, "DD")
However I keep getting an error on the WeekEndDate when selecting a Saturday.
Does anyone have any idea what I'm doing wrong?
Thank you for any help!
-MichelleWell, I never got an answer from the forum here, but to help out others - here is what I did:
This was all done in FormCalc.
The object WeekEndDate Date/Time Field has a set pattern date{MM/DD/YYYY} in the Object Field Pattern in LiveCycle.
BUT, the Scripting required the pattern to be YYYY-MM-DD
Why? I have no flipping clue. It won't work any other way for me.
Also this item requires a Saturday Date to be chosen. Days of the week are designated by numbers (Sunday = 1, Monday = 2, etc.)
The line <>7 means that if the day is not Saturday (7) then the error message "Ending date must be a Saturday" will appear.
This is the Exit event Script:
TopmostSubform.Page1.Requestor.WeekEndDate::exit- (FormCalc, client)
var endDate = Date2Num($,"YYYY-MM-DD")
var dayOfWeek = Num2Date(endDate, "E")
if (dayOfWeek <> 7) then
xfa.host.messageBox("Ending date must be a Saturday")
$ = null
xfa.host.setFocus("$")
endif
The individual Date cells are set to a Date/Time Field with no pattern set in the Object Field Pattern in LiveCycle.
The coding below designates a MM/DD pattern.
Each individual field has it's own scripting, with the appropriate minus calculation - #
This is the Calculate script for the Sunday cell:
TopmostSubform.Page1.#subform[1].InputTable.Row1[0].Date1::calculate - (FormCalc, client)
var dateNum = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY") - 6
$.rawValue = num2date(dateNum,"MM/DD")
And the Saturday cell, that needed to display the Saturday End Date has the following Script, with NO minus number:
TopmostSubform.Page1.#subform[1].InputTable.Row1[0].Date7::calculate - (FormCalc, client)
var dateNum = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY")
$.rawValue = num2date(dateNum,"MM/DD")
Why did I include this all here?
Because this whole project has been gawd-awful, and hopefully these insights can help another struggle forms designer understand the FormCalc scripting used.
-M -
Best way to derive a "week ending" date using the Derived Column Transformations
Hi, I have an interesting challenge. I am working on creating a BI DB that contains timesheet data. The data contains a column representing the date "worked" ([Date]. Nearly all output reporting is based on a timesheeting week that end on
a Wednesday. My thinking has been to create a derived column "WE" (week ending) that represents the entries of the preceding 6 days.
(Originally I entertained deriving this value view SQL view - however we are talking about a DB that is is a substantial DB (excess of 100M timesheet bookings) and an index on the WE field is warranted) so decided a derived WE column was best approach.
The Date field is represented from a SAP format (German long dated format) - however I cannot use the convert option ;( in the TE.
The Date field is derived via: (DT_DATE)(SUBSTRING([Date ],7,4) + "-" + SUBSTRING([Date ],4,2) + "-" + SUBSTRING([Date ],1,2))
I would welcome some recommendation on how to best derive a WE column. (The DT_DATE format is not susceptible to a /7, mod7 operation).
Thanks in advance,
/LTry this solution :
http://stackoverflow.com/questions/1803987/how-do-i-exclude-weekend-days-in-a-sql-server-query -
Grouping by week using Date column
I have a table with a date column. I'd like to generate a report grouping all entries by week. Is this possible with the date expressions/functions within Oracle?
ThanksWhat is your definition of a week?
select to_char(sysdate, 'IW') from dual
will return 21 which is the week of the year according to the ISO standard
So a query such as
SELECT TO_CHAR(mydate, 'IW'), col1, col2
FROM mytable
GROUP BY TO_CHAR(mydate, 'IW')
will group the data by the ISO week.
You may also want to select the year as part of the query.
null -
FM to find week start and end date on the basis of a given date
Hi Everyone,
I have a requirement in which I require the week start and end date of any given date.
For eg: The given date is Wednesday 24.03.2010, I need a function module to calculate the week start date ie. Monday 22.03.2010 and week end date ie. Sunday 28.03.2010 on the basis of that date.
Any input to this query would be helpful.
Thanks,
Nimisha Agarwal
Edited by: Nimisha Agarwal on Jul 7, 2010 7:47 AMHI nimisha,
many posts r there for this .
Kindly check before posting
anyways this FM will serve u r purpose.
GET_WEEK_INFO_BASED_ON_DATE -
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 . -
Forms - "Weekend Ending Date" used to Poplulate Date Fields
Hello,
This is my first topic, so my apologies if it is then wrong place...
Quick question (using Acrobat 9.0 CS4 Pro Ext.),
I am trying to set up a form where I input the week ending date (xx-xx-xx) into field "date_1"
Once the week-ending date is input into "date_1", I would like the following fields to populate with the dates from the prior week (Monday-Sunday) "date_2", "date_3", "date_4", "date_5", "date_6", "date_7", and "date_8" respectively. Where the week-ending date, "date_1" equals the Sunday date "date_8"
Example:
*Input 02-21-10 into field "date_1"
*Auto-populate the following:
"date_2" 02-15-10
"date_3" 02-16-10
"date_4" 02-17-10
"date_5" 02-18-10
"date_6" 02-19-10
"date_7" 02-20-10
"date_8" 02-21-10
Can I use any formula with some sort of "date"+1 calulation like you can in MS Excel, or must I use some sort of script? I am not familiar with formulas or scripts in Acrobat, so any help would be appreciated. Hope I explained sufficiently.
Thank you all in advance!Anybody?
-
Day by Day Data exluding week ends and holidays.
Hi,
Can any give me solution for below requirement...
13/06/2007 14/06/2007 15/06/2006 18/06/2007 .. till 20 days
of Lines Processed 15 18 13 19 .........
of Units Processed 17 14 10 11 .........
of Lines P Received 16 19 20 16 .........
of Units P Received 19 22 40 17 .........
here the user will give the input of first value(13/06/2007), now we have to display 19 days after user input(13/06/2007) value and we need to skip the holidays and week ends in the report.
In the above report 16/06/2006 & 17/06/2006 are week ends thats why those 2 days data is not there.
Please suggest me how can we do it this requirement.
Thanks & Regards
Venkatbefore you get a dozen of answers using artifice like all_objects or connect by, I post you this one
create table date_table(d date primary key);
exec for d in 0..10000 loop insert into date_table values(date '1980-01-01'+d);end loop;commit
select d,count(hiredate) from date_table left join emp on (d=hiredate) where d between date '1980-12-01' and date '1980-12-31' group by d order by d;
D COUNT(HIREDATE)
01-DEC-80 0
02-DEC-80 0
03-DEC-80 0
04-DEC-80 0
05-DEC-80 0
06-DEC-80 0
07-DEC-80 0
08-DEC-80 0
09-DEC-80 0
10-DEC-80 0
11-DEC-80 0
12-DEC-80 0
13-DEC-80 0
14-DEC-80 0
15-DEC-80 0
16-DEC-80 0
17-DEC-80 1
18-DEC-80 0
19-DEC-80 0
20-DEC-80 0
21-DEC-80 0
22-DEC-80 0
23-DEC-80 0
24-DEC-80 0
25-DEC-80 0
26-DEC-80 0
27-DEC-80 0
28-DEC-80 0
29-DEC-80 0
30-DEC-80 0
31-DEC-80 0
31 rows selected.Message was edited by:
Laurent Schneider
primary key added for integrity and performance
Maybe you are looking for
-
Mini DVI - Video Adapter, Not Working?
I would like to use my standard definition television as an external display for my Macbook (late 2008 model running OS X 10.6.6), so I purchased a mini DVI-video adapter. I connected the adapter to my Macbook, then an S-video cable to the adapter, a
-
how to download the parallels desktop 3.0 for mac
-
ITunes Video Podcasts and Photoshop CS5 not playing together.
i just got a MBP with all the trimmings and have been having a problem since i got it. As a photographer I need Photoshop CS5 and have installed it as normal on my new MBP. Every time I am playing a video podcast from my iTunes library and let's say
-
When do different scopes get removed from memory?
Hi, Here's what I've got. I have a cfc that processes complex xml documents for product catalogs. We've got functions in that cfc to process various parts of each document, with parts being passed to the function (product object struct, option stru
-
Hi, I'm trying to create a very simple excel line chart using the report generator toolkit. I have tried both the Excel Easy Graph and Excel Insert Graph vi's (using xlLine type) but cannot get them to output the type of graph im looking for. Usin