Getting count of days
I have a query...
SELECT
to_char(t.traffichour, 'Day') as theDay,
to_char(t.traffichour, 'D') as day,
to_char(t.traffichour, 'hh24') as hour,
Round(100*SafeDivide(sum(t.traffic) over ( PARTITION BY to_char(t.traffichour, 'D'), to_char(t.traffichour, 'hh24') ),sum(t.traffic) over ( PARTITION BY to_char(t.traffichour, 'D') ))) as pct, traffic
FROM
traffic.traffic_stage t,
store_info b
WHERE t.store_id = b.unitynbr
AND b.pslocation = 2838
AND trunc(t.TRAFFICHOUR) > sysdate - 180
that returns the day name, number, hour of day, a traffic number and percentage over the past 180 days..
How can I get the count of the days also.. for example how many mondays, tuesdays, wednesdays, etc have there been in the past 180 days?
I tried
count(to_char(t.traffichour, 'D') over (partition by trunc(t.traffichour)) as dayCount,
but to_char in count(to_char(t.traffichour,'D') gets hightlighted and I get 'window function not allowed here'..
Thanks guys!
Hi,
Try this:
SQL> l
1 select count(to_char(date#,'d')) as NumDay, to_char(date#,'DAY') day#
2 from (select sysdate-delay+level as date#
3 from (select &delay+1 as delay from dual)
4 connect by level <= delay)
5 group by to_char(date#,'DAY'),to_char(date#,'d')
6* order by to_char(date#,'d')
SQL> /
Enter value for delay: 180
old 3: from (select &delay+1 as delay from dual)
new 3: from (select 180+1 as delay from dual)
NUMDAY DAY#
26 MONDAY
26 TUESDAY
26 WEDNESDAY
26 THURSDAY
25 FRIDAY
26 SATURDAY
26 SUNDAY
7 rows selected.
SQL> /
Enter value for delay: 7
old 3: from (select &delay+1 as delay from dual)
new 3: from (select 7+1 as delay from dual)
NUMDAY DAY#
1 MONDAY
1 TUESDAY
1 WEDNESDAY
2 THURSDAY <-- Today and today-7 (29 dec. 05)
1 FRIDAY
1 SATURDAY
1 SUNDAY
7 rows selected.
SQL> Nicolas.
Message was edited by:
N. Gasparotto
Similar Messages
-
Count of days exclude sat'day and sunday
Hi,
I'm able to get count of days in current month as of today but not able to exclude weekends. Please advise.
My query
SELECT TRUNC(SYSDATE)-TRUNC(SYSDATE,'MM') FROM DUAL
I want very simple query something like show below. please don't use connect and level key words because they aren't supported by OBIEE.
SELECT TRUNC(SYSDATE)-TRUNC(SYSDATE,'MM') FROM DUAL
where wday not in ('sat','sun');
Thanks
ASHCheer this
http://siebel.ittoolbox.com/groups/technical-functional/siebel-analytics-l/calcuate-the-difference-between-two-given-dates-excluding-weekends-2041897
Re: Date Differance in days (except Sat/Sun)
Cheers
Nawneet -
Any FM to get count of each week day for the given date range
Hi guys,
Any FM to get count of each week day for the given date range?
eg: If i give 14/07/2008 to 14/08/2008
I need to find how many Mondays, tuesdays...sundays in this given date range.
If not single FM is available, any logic that gives above result is also appreciated.
Thanks,
Vinod.hi Vinod,
this is not a full solution, I just give you a basic idea:
DATA : lv_start TYPE sy-datum VALUE '20080714',
lv_end TYPE sy-datum VALUE '20080814'.
WHILE lv_start LE lv_end.
CALL FUNCTION 'FTR_DAY_GET_TEXT'
EXPORTING
pi_date = lv_start.
* IMPORTING
* PE_DAY_TEXT1 =
* PE_DAY_TEXT2 =
* PE_DAY =
* you have to summarize the output here somehow...
lv_start = lv_start + 1.
ENDWHILE.
hope this helps
ec -
Hey huys,
I have a problem with the count of working days in the report I am developing.
I make the count of days with TIMESTAMPDIFF but this return all days between Start Date and end date and I Want only working days. I have a column that says if the day is a work day or not.
I don´t have any idea how I make the comparison day by day.
Can any suggest how I do it.
CumpzWe can try to create a function in DB which returns the Number of Working Days on passing the Start Date and End Date of Campaign Calendar
By you saying there is a column "Work Day" with flag "Yes" or "NO", I assume there is a table called Campaign Calendar which may provide this info like if each and every day is working day or not.
For ex:
Work_Day Flag
02-SEP-13 00:00:00 YES
03-SEP-13 00:00:00 YES
04-SEP-13 00:00:00 YES
05-SEP-13 00:00:00 YES
06-SEP-13 00:00:00 YES
07-SEP-13 00:00:00 NO
08-SEP-13 00:00:00 NO
If the above is the case, then try to create a function as below which return number of working days between two dates
CREATE
FUNCTION DATE_DIFF(ST DATE, ED DATE) RETURN NUMBER
IS NO_OF_WDAYS NUMBER;
DT1 DATE := ST; ---VARIABLE TO HOLD START DATE
CHR1 VARCHAR2(10); ----VARIABLE TO HOLD FLAG FOR EACH DATE
HOLIDAY NUMBER := 0; ----COUNTER WHICH GIVES US NUMBER OF HOLIDAYS BETWEEN TWO DATES INCLUDING SATURDAYS AND SUNDAYS
BEGIN
NO_OF_WDAYS := TRUNC(ED - ST);
LOOP
SELECT Work_Day /* THE COLUMN WHICH HOLDS THE FLAG*/
INTO CHR1
FROM CAMPAIGN_CALENDAR /* THE TABLE WHICH HAS THE INFO */
WHERE DATE_COLUMN = DT1;
IF(CHR1 = 'NO') THEN
HOLIDAY := HOLIDAY + 1;
END IF;
DT1 := DT1 + 1;
EXIT WHEN DT1 > ED;
END LOOP;
NO_OF_WDAYS := NO_OF_WDAYS - HOLIDAY;
RETURN NO_OF_WDAYS;
END DATE_DIFF;
Once the above function is written, use Evaluate function in the RPD and pass both the columns as parameters.
EVALUATE('DATE_DIFF(%1,%2)' ,Campaign Start Date,Campaign End Date)
Whenever the column gets pulled in the report, the above db function will be fired hence resulting in Number of Working days.
Hope its helpful
Srikanth -
I want to get number of days in the month I've chosen from Timeline slicer.
I want to get number of days in the month
I've chosen from Timeline slicer,
does anyone know how to do?
The problem I want to solve is to divide
the number of customer visits as a salesman
made during a month by the number of
days in the month.Excel 2013 Pro Plus with PowerPivot.
Count working days per month
considering weekends and holidays.
With help from book:
"Building Data Models with PowerPivot"
by Alberto Ferrari and Marco Russo.
Easy. Not.
http://www.mediafire.com/view/rw78t1y3bg8vm0c/04_10_15.xlsx -
Hi Community,
I have posted this question in Acrobat.Answers.com
Count Elapsed Days (JavaScript)
The script provided there is almost works. But If SaleesDate is Jan 1, then this is showing wrong output. ie;
Jan 1, 2014 showing 3366, but should be 41. Only issue if Date is Jan 1.
Also i have two more request on this same.
1. If SalesDate is empty, then show as empty.
2. Always use 000 format in elapsed days. so need to show like 001, 010, 100. So with Lastdigit is like 4001, 4010, 4100
Thanks a lot for your valuable time.
Thank you
AdobeFanThere are a number of trip points here.
Try the following script for the year and elapsed number of days field:
function GetField(cName) {
// get field object with error checking;
var oField = this.getField(cName);
if(oField == null) app.alert("Error accessing field named " + cName + "\nPlease check that this is the correct field name.", 1, 0);
return oField;
} // end GetField function;
function Scand(cFormat, cDateString) {
// using format convert date string to date object with error checking;
var oDate = util.scand(cFormat, cDateString);
if(oDate == null) app.alert("Error converting date " + cDateString + " with format of " + cFormat + "\nPlease check date string and date formatting.", 1, 0);
return oDate;
} // end Scand function;
event.value = ""; // clear the result field;
var cFieldName = "SalesDate"; // field name;
var oSalesField = GetField(cFieldName); // get field object;
if(oSalesField != null && oSalesField.valueAsString != "") {
oSalesDate = Scand("dd-mmmm-yyyy", oSalesField.valueAsString); // convert date string to date object;
// console.println(oSalesDate + " sales date");
var oStartDate = Scand("yyyy-mm-dd", oSalesDate.getFullYear() + "-01-01"); // date object for 1-jan for year of sale;
// console.println(oStartDate + " Start date");
var nDiff = oSalesDate.getTime() - oStartDate.getTime(); //elapsed milliseconds;
nDiff = Math.ceil(nDiff / (1000 * 60 * 60 * 24)) + 1; // days inlcuding last day;
// console.println(nDiff);
// set field value inlcude last digit of year and elapsed days;
event.value = String(oSalesDate.getFullYear()).substr(3,1) + util.printf("%,103.0f", nDiff);
One has to count the start day as a full day and then there is the 3 leading zero formatting. -
I purchased a student subscription to Creative Cloud. I got the confirming email. When I attempted to install the aps, kept getting a 30-day trial for all the aps. In the case of Photoshop, it was expired. How do I activate my Creative Cloud?
ChristinaW1111 for information on how to resolve the connection error preventing the active membership from authorizing then please see Sign in, activation, or connection errors | CS5.5 and later. If you have any questions regarding the steps listed within the document you are welcome to update this discussion.
-
How to get the last day of calweek
Hi Guys,
Is there any function module to get the last day of the calendarweek.
I want to show that last date of calweek in my column heading.You can use the Calender class...
Calendar c = Calendar.getInstance();
and then something like...
c.add(c.MONTH, 1);
int dayOfMonth = c.get(Calender.MONTH);
c.add(c.DAY_OF_MONTH, - (dayOfMonth-1) );
other usefull functions are:
System.out.println(" YEAR : " + c.get(Calendar.YEAR));
System.out.println(" MONTH : " + c.get(Calendar.MONTH));
System.out.println(" DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH));
System.out.println(" DAY_OF_WEEK : " + c.get(Calendar.DAY_OF_WEEK));
System.out.println(" DAY_OF_YEAR : " + c.get(Calendar.DAY_OF_YEAR));
System.out.println(" WEEK_OF_YEAR : " + c.get(Calendar.WEEK_OF_YEAR));
System.out.println(" WEEK_OF_MONTH : " + c.get(Calendar.WEEK_OF_MONTH));
System.out.println(" DAY_OF_WEEK_IN_MONTH : " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println(" HOUR : " + c.get(Calendar.HOUR));
System.out.println(" AM_PM : " + c.get(Calendar.AM_PM));
System.out.println(" HOUR_OF_DAY (24-hour): " + c.get(Calendar.HOUR_OF_DAY));
System.out.println(" MINUTE : " + c.get(Calendar.MINUTE));
System.out.println(" SECOND : " + c.get(Calendar.SECOND));
System.out.println();*/ -
How to get the last day of the next month?
Hi all.
I need to get the last day of the next month. E.g. if the date is 20.03.2008 I need to get 30.04.2008.
Is there any FM for it?
TIA, Nikolai.hi Nikolai,
pls. have a look athe following piece of code:
PARAMETERS : p_date TYPE sy-datum.
DATA : gv_res TYPE sy-datum.
CALL FUNCTION 'CALCULATE_DATE'
EXPORTING
* DAYS = '0'
months = '2'
start_date = p_date
IMPORTING
result_date = gv_res.
==> Now you have (gv_res) 2 months later as today
gv_res+6(2) = '01'. ==> gv_res is first day of next-next month
gv_res = gv_res - 1. ==> gv_res is last day of next month
hope this helps
ec -
How to get the last day of the payroll period
Hi all,
I need to get the last day of the payroll period e.g. last day of Jan 2007 is 31 Jan 2007. Can anyone suggest as to how to get it?
Thanks,
MadhuT549S contains the payroll periods with pay date. T549Q contains the begin and end dates of the payroll period.
You can select from the appropriate table (or from both depending on your given data) to get the end date of the period.
Hope that helps.
Mary -
How to get the last day of the week?
Hii
i can get the calender week number for any given date using
SELECT to_char(to_date('04/04/2011','MM/DD/YYYY'),'WW') FROM dual
can any body tell me, how to get the last day of that week ?
and the answer should be 04/08/2011(8th april )
thanks
San
Edited by: sandeep9 on Apr 4, 2011 3:50 AMHi, San,
Here's one way:
WITH sample_data AS
SELECT DATE '2011-04-04' AS dt
FROM dual
SELECT dt
, TO_CHAR (dt, 'WW') AS week_num
, NEXT_DAY ( dt - 1
, TO_CHAR ( TRUNC (dt, 'YEAR') - 1
, 'Day'
) AS end_o_week
FROM sample_data;Another way is to use date arrithmetic:
WITH sample_data AS
SELECT DATE '2011-04-09' AS dt
FROM dual
SELECT dt
, TO_CHAR (dt, 'WW') AS week_num
, TRUNC (dt, 'YEAR')
+ (7 * CEIL ( (dt - (TRUNC (dt, 'YEAR') - 1))
/ 7
- 1 AS using_date_arithmetic
FROM sample_data; -
How to get the last day of a month?
HI,
I want to know how to get the last day of a month.
In my JClient form, I tried to get it by using oracle.sql.Date method, that is:
lastday=oracle.sql.Date anydate.lastDayOfMonth();
But it does not work. The result is lastday=anydate.
Why?
StephenYou can use the Calender class...
Calendar c = Calendar.getInstance();
and then something like...
c.add(c.MONTH, 1);
int dayOfMonth = c.get(Calender.MONTH);
c.add(c.DAY_OF_MONTH, - (dayOfMonth-1) );
other usefull functions are:
System.out.println(" YEAR : " + c.get(Calendar.YEAR));
System.out.println(" MONTH : " + c.get(Calendar.MONTH));
System.out.println(" DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH));
System.out.println(" DAY_OF_WEEK : " + c.get(Calendar.DAY_OF_WEEK));
System.out.println(" DAY_OF_YEAR : " + c.get(Calendar.DAY_OF_YEAR));
System.out.println(" WEEK_OF_YEAR : " + c.get(Calendar.WEEK_OF_YEAR));
System.out.println(" WEEK_OF_MONTH : " + c.get(Calendar.WEEK_OF_MONTH));
System.out.println(" DAY_OF_WEEK_IN_MONTH : " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println(" HOUR : " + c.get(Calendar.HOUR));
System.out.println(" AM_PM : " + c.get(Calendar.AM_PM));
System.out.println(" HOUR_OF_DAY (24-hour): " + c.get(Calendar.HOUR_OF_DAY));
System.out.println(" MINUTE : " + c.get(Calendar.MINUTE));
System.out.println(" SECOND : " + c.get(Calendar.SECOND));
System.out.println();*/ -
How to get the last day according to fiscal period input in selection scree
Hello expert
how to get the last day of fiscal period input.
the fiscal period inculdes 1-16
when fiscal period is greater than 12, only calculate the last day of 12nd month
your solution will be apprecaited, FM existing?
thank you
KevinHi,
when you give a particular date in any month
the following fm will give you the last date of that month
here you can give
R_FDATE-HIGH as 01 and month as the period you wnat and year for current year
concatenates '01' month year into r_fdate-high separated by '.'.
then it will give g_ltdt for that month and year which wil be the last date of that month
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = R_FDATE-HIGH
IMPORTING
LAST_DAY_OF_MONTH = G_LTDT
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
thanks & regards,
Venkatesh -
Background job getting failed every day
Hi,
This background job getting failed every day.But this job was running fine initial periord.Please help me out this issue.
SAP_REORG_UPDATERECORDS
SAP_WP_CACHE_RELOAD_FULL
SLCA_LCK_SYNCHOWNERS
Regards
Naanas.If this is R/3, then none of the above jobs should exist in the system, if scheduled by default with other standard jobs, then these should be removed
Note 1034532 - Changes for standard jobs
Note 931436 - SLCA_LCK_SYNCHOWNERS standard job terminates -
How can I get a one day development session for experienced developers in Malaysia?
I have a team of experienced and capable developers in Malaysia. We have just launched a new product and the guys put in a huge effort to get us there.
But our product does on work on ipads or iphones because it is largely in Silverlight. So we might build a separate application soon for mobile and apple based devices.
I would like to reward the guys with a day (or maybe two) where they can learn to program for ipads. I would like a hands on lab from and experienced developer rather than a basic training course. I would like the guys to get their hands dirty and play with the technology even if all we get from the day is fun, experimentation and hopefully a taste of a new capability that we could develop.
I also have usability guys so it would be ideal if we could have a day for them too, but my primary aim is to let the developers tackle something new with no critical deadline or strictly contained business requirements.
What should I do? Is there a guru developer who could spend a day with the team?Email you care to put here you can share?
Just long enough to grab and then edit out will be ok.
Ken
Maybe you are looking for
-
Restricting Cost Elements in Internal Orders
I am setting up new order types for our Marketing Department. I want to ensure the only costs charged there are Marketing Costs (ie a small range of Cost elements). I've put the range into the allocation structure, but that only seems to control sett
-
How to text to someone who doesn't have an iphone
how do you text someone who doesn't have an iphone
-
I Am unable to do updates or download anything since updating to iOS 7.1. Can anyone help?
-
So, is version 8.2.4 safe now? :-/
So, I just got a new "toy": I was able to upgrade my old Acrobat Standard 5.x to Acrobat Professional 8 by purchasing a legitimate, unopened, sealed copy of the Acrobat Professional 8 update version for under $30 shipped. (Version 9 requires an In
-
I/O error when trying to connect iPod to PC
I'm having issues with iTunes / iPod because every time I've tried to connect it to my PC it says the folder has been moved and it not accesible, and this is due to an I/O error. I've tried uninstalling the programme and then re-installing the latest