Count Elapsed Days
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
AdobeFan
There 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.
Similar Messages
-
Elapse days - calculation from month and year
Duplicate thread ...
coding required for converting month into days
I have Month and year field in my DSO --Year( 2009), Month(4)
I want below logic to calculate -
MTD qty % = (qty * elapse days) / no of days in month
so from the above, I want to know,
1. How can we get the no of days from the above 2 objects (year and month).
2. Elapse days are the days that are over from current date to Ist day of that month.
eg: current date - 04.03.2009 , 1st day of the month - 04.01.2009,
elapse days = 2. (you need to consider all days in the month, not only working days)
so my questions is how can we get, # of days n a month from above 2 fields and elapse days based on the above condition.
also want to know, where can I have the logic in transformations or query level.
please provide your suggestions.
Thanks,
Pra
Edited by: Arun Varadarajan on Apr 5, 2009 10:44 PM
Edited by: Arun Varadarajan on Apr 5, 2009 10:45 PMHello,
I think the sample program below does what you ask: it finds the days in the month (bit of an overkill to use function modules for that) and then computes the QTD.
Note that the internal string representation of a data variable is always YYYYMMDD, regardless of the "externalized" form (e.g. yyyy/mm/dd or dd.mm.yyyy), so this code will work regardless of your custom date format.
Regards,
Mark
REPORT zqty_to_date.
PARAMETERS:
p_date TYPE dats,
p_qty TYPE i.
DATA:
days TYPE i,
n_year TYPE numc4,
n_month TYPE numc2,
n_day TYPE numc2,
qtd(6) TYPE p DECIMALS 1.
START-OF-SELECTION.
n_year = p_date+0(4).
n_month = p_date+4(2).
n_day = p_date+6(2).
PERFORM days_in_month USING n_year n_month CHANGING days.
qtd = ( p_qty * ( n_day - 1 ) ) / days.
WRITE: / 'Days in month:', days,
/ 'Qty to date :', qtd.
*& Form days_in_month
* text
FORM days_in_month USING year month CHANGING days.
DATA: ymod4 TYPE i,
ymod100 TYPE i,
ymod400 TYPE i.
CASE month.
WHEN 4 OR 6 OR 9 OR 11.
days = 30.
WHEN 2.
ymod4 = year MOD 4.
ymod100 = year MOD 100.
ymod400 = year MOD 400.
IF ( ymod4 = 0 AND ymod100 > 0 ) OR ( ymod100 = 0 AND ymod400 = 0 ).
days = 29.
ELSE.
days = 28.
ENDIF.
WHEN OTHERS.
days = 31.
ENDCASE.
ENDFORM. "days_in_month -
How to count the days between Date Range using OO ABAP?
hi experts,
i want to count the days between Date Range using OO ABAP for that which class and method can i use?.
Thanks,
Mahesh.Not sure I understand the requirement for it to be OO, but you could always write your own (i.e. use this):
REPORT zz_date_diff.
CLASS date_diff DEFINITION.
PUBLIC SECTION.
METHODS diff IMPORTING i_date_fm TYPE d
i_date_to TYPE d
EXPORTING e_days TYPE i.
ENDCLASS."
CLASS date_diff IMPLEMENTATION.
METHOD diff.
e_days = i_date_to - i_date_fm.
ENDMETHOD."
ENDCLASS."
DATA: g_ref TYPE REF TO date_diff,
g_days TYPE i,
g_date_fm TYPE d VALUE '20080101',
g_date_to TYPE d VALUE '20090101'.
START-OF-SELECTION.
CREATE OBJECT g_ref.
CALL METHOD g_ref->diff
EXPORTING
i_date_fm = g_date_fm
i_date_to = g_date_to
IMPORTING
e_days = g_days.
WRITE g_days. -
Count consecutive days in array
Hi,
I'm looking for an algorithm to count consecutive days in array, but i don't find one.
for example, if i have this array.
2009/07/01
2009/07/02
2009/07/03
2009/07/06
2009/07/08
2009/07/09
2009/07/10
2009/07/11
The result be
3
1
4
Anyone have one?
Thanks for all.jverd wrote:
kajbj wrote:
It's a fairly specialist algorithm so you are unlikely to find someone to post a solution. By just keeping a reference to the previous date, it is easy to iterate though the list counting consecutive dates.I think the trick to making this algorithm sucessful is to make sure that when you change months your algorithm doesn't set consec_days to 0 Why not?Presumably he's talking about this case:
7/31
8/1
and not this case
7/1
8/1
So he really should have said, "...when you increment month by one, or from 12 to 1, and the day went from the last day of the old month to 1, don't set consec_days to 0"Ok. I would use the Calendar class and SimpleDateFormat. The tricky part would otherwise be to keep track of days per month, and leap year. -
Is there a background for iphone that counts down days??
Is there an app or background that will count down days??
Counts down days to like a trip or to an event of some sort.
-
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 -
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 -
HELP: PCR using AAU** can not count absence days that less than a day
Hi, experts
I have customized a PCR using AAU**
But it can not count absence days that less than a day which is maintained in IT 2001 ,
such as unpaid leave. However it can correctly count absence days that last one day or above .
The issue is so strange for me, so please give me some advice.
Thanks a lot !
Morgan from Shanghai, China
2011-6-10Morgan
1 alternative approach is as follows:
Step 1: Ensure your absence type have already been mapped to an absence valuation rule
Step 2: In your absence valuation rule, (goto SM30 > V_t554c), assign a new wage type to capture the number of days
The wage type in step 2 should be created such that its attributes is to help your capture number of days of your unpaid
absence type when it is evaluated by your payroll schema
Final Step: You should be able to capture half day absences with such a wage type when you run your payroll calculations
Should you need to utilize such a wage type for subsequent calculation processing in your payroll schema, you may have to develop your own customer payroll calculation rules to do so -
After several tests, I'm pretty sure that the policy "Interactive logon: Prompt user to change password before expiration" is counting the wrong days. (Note: this policy is in Windows Settings > Security Settings > Local Policies > Security
Options) So I think I should post this in the forum in the hope that it could be helpful to others in the same case as me, esp if the policy is pushed out as a domain-wide policy.
First, the context of the test, ie domain-wide policy settings:
1. Password minimum age = 2 days
2. Password maximum age = 4 days
3. Prompt user to change password before expiration = 2 days
If everything is going fine, users will be asked to change password when it is changeable (ie it has reached the minimum age). However, it turns out that users are prompted BEFORE they can change password. Look at the image below that I got in
Win7:
(In WinXP, we have similar prompt when user has just logged in)
Look at the clock: it's 13:16 (04/12/2013). Then look at the DOS window in which I ran the "net user /domain" command and read the line "Password expires": it's shown
06/12/2013 18:09:04.
A little math would tell me that if users are prompted to change password *2 days* before expiration, the dialog will appear
ONLY AFTER 04/12/2013 18:09:04. But since the prompt is shown at 13:16 (ie well before 18:09), that mean the "prompt user...." policy makes mistakes in calculating the moment to show the prompt.
In other words, if we have the policy set like this:
Prompt user to change password before expiration =
N days
The prompt will actually appear from N+1 days before expiration.
I would consider this as a bug, but I also suppose it's hard to make Microsoft fix it. So that's why I make this post to warn others. In my case, I have received several calls from users complaining that they were prompted to change password
but their new passwords were always refused and they had no idea what went wrong. And it took me a lot of effort to sort out what really went wrong. And in order to work around this stupid bug, I have to change the "Prompt user...." policy
to N-1 days (before expiration) instead of N days previously.
Hope this helpHi,
Based on my research, you are right that the prompt policy is implemented by date, which is by design.
“Set
Interactive logon: Prompt user to change password before expiration to 5 days. When their password expiration
date is 5 or fewer days away, users will see a dialog box each time they log on to the domain”, I quoted this sentence from the article below:
Interactive logon: Prompt user to change password before expiration
http://technet.microsoft.com/en-us/library/jj852243.aspx
The problem is consistency! For Minimum/Maximum password age properties, they are also defined for
days as well. But for them, days are exact days, ie a
multiple of exactly 24 hours. There is an "Explain" tab for every parameter, but even if you read them through, you can't tell if day means strict multiple of 24 hours or loose definition of days. I'll leave the exercise to you to read
them if you like and spare me the article from your KB library.
As for the password minimum age part, what I mean is that is why users can’t not change their password within 2 days when the prompt appears before the changeable time.
Anyway, I agree with you that we need to be careful when we configure the password policy because the Prompt policy is not doing calculation by hours.
Miss, the 2 days is just a TEST EXAMPLE. Let's say it's
N days if you was unable to understand. I wouldn't change N days to N-1 days because of this stupid GUI bug. As I said earlier and let me repeat it once more,
Minimum password age = N days is a security policy and it is more important than the user prompt and no security officer with sane mind will change this. -
Count the days Crystal!!
Afternoon all,
I have found a strange thing here, I am using datediff to find out the number of days a job has taken to be shipped.
I found out that Crystal report does not include the date (day of order) and counts from the next following day.
Example
Order placed = 25/06/2008
Order Shipped = 27/06/2008
Days took = 2 (According to Crystal)
However,
According to our old system the same job took 3 days
Order placed = 25/06/2008
Order Shipped = 27/06/2008
Days took = 3 (According to our old system)
How can I make the Crystal count the order day as well!??
many thanks
Kind Regards
JehanzebThanks guys!!
I do not regert joining this forum! There are sooo many hands to help!
Yes! even though the order is placed at 6pm it takes it as 1 day (the old system because our ordering system runs 24 hours (online).)
Oki now come to a stupid question.
How can I add 1 day into my formula?
I have a formula:
//weekday({order_progress.date_created},crMonday)- day({bank_hol.holiday_date});
//weekday({order_header.date_entered},crMonday)- day({bank_hol.holiday_date});
if {order_progress.order_status}= 77 then
if datediff('d',{order_header.date_entered},{order_header.act_despatch}) < 9 then
1
else
2;
if datediff('d',{order_header.date_entered},{order_header.act_despatch}) <= 8 then
totext(datediff('d',{order_header.date_entered},{order_header.act_despatch}),0,'')
else
"9+";
In the above coding, Date Entered is the date when order is placed and Despatched date is the date when the order is shipped. How can I add 1 day to into this formula?
Many thanks
Regards
Jehanzeb
Edited by: Jehanzeb Navid on Jul 22, 2008 3:11 PM
Edit: I tried this method but didn't work
if datediff('d',{order_header.date_entered}+1,{order_header.act_despatch}+1) < 9 then
1
else
2;
if datediff('d',{order_header.date_entered}+1,{order_header.act_despatch}+1) <= 8 then
totext(datediff('d',{order_header.date_entered}+1,{order_header.act_despatch}+1),0,'')
else
"9+"; -
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 -
Building Query to count # of [day] for last yr
This will be used in Reports 6.0
I have created a query that should count the number of (example : Tuesdays) for the prior year. I can't figure how to do it....
Here's my query that returns only 1:
select count(next_day(sysdate,to_char(to_date(sysdate), 'DAY')))days from dualIt depends on whether you want a single query (a difficult task, you may need to maintain a calendar table) or a function (or even PL SQL block). If its a function then the code would be:
DECLARE
yy_start DATE := TO_DATE('01-01-'| |TO_CHAR(TRUNC(SYSDATE),'YYYY') - 1,'YYYY');
yy_end DATE := LAST_DAY(ADD_MONTHS(yy_start,12));
tues_count NUMBER := 0;
BEGIN
FOR i IN 1..yy_end - yy_start LOOP
IF TO_CHAR(yy_start + i - 1,'DAY') = 'TUESDAY' THEN
tues_count := tues_count + 1;
END IF;
END LOOP;
--RRTURN tues_count;
END; -
Counts entry days within a month.
I keep a list of days that I work for a certain company. There are about 50 dates in a column (ie: 04/13/10, 04/28/10, 05/02/10, etc.). I want to count how many days worked are in January, February, March, .... How do I do this?
Hi Erik,
Welcome to Apple Discussions and the Numbers '09 forum.
=IF(ISBLANK(Date),"",(MONTHNAME(MONTH(Date))))
extracts the month (number) than converts it to the monthname.
=YEAR(Date)
extracts the year.
If you want both in the same cell, you'll need to concatenate the two results, separating them with whatever text you want.
=IF(ISBLANK(Date),"",(MONTHNAME(MONTH(Date))&", "&YEAR(Date)))
Date here is the cell in the column headed Date, in the same row as the cell containing the formula.
One of the best pieces of advice I can give a new user of Numbers, which I'm assuming from this being your first post to the forum,you are, is to spend an hour or so reading/browsing the Numbers '09 User Guide. If you haven't already done so, go to the Help menu in Numbers and download that guide, and the iWork formulas and Functions User Guide. Both are well written, the Numbers guide gives an overview of the applications design and features, and the Formulas and Functions guide describes each of the functions supported in Numbers (and in tables in the other iWork applications), with examples of how each works. The Date and Time functions, including MONTH, MONTHNAME AND YEAR are discussed (with further examples) in Chapter 3.
Regards,
Barry -
Count # of days in stampdate column and send email if days 30
I want to create a procedure so that it will be called to see if the user has updated their project within the last 30 days.
I have the following tables VALIDUSER table has UserID and EmailAddress columns, and FOLDER table has StampUser, StampDate and FolderType columns.
Whenever a user updates a project of FolderType ABC, the StampDate in the FOLDER table is update to reflect that date.
The procedure will look at the StampDate to see if that date is within the last 30 days from today.
If the date is either null or more than 30 days from today's date, an email will be sent to the user reminding them to update the project.
Message was edited by:
user644765
Message was edited by:
user644765Am still stuck on this one. I want to create a procedure that will be called to send an email to the assigneduser if they have not updated their foldertype HJ in the last 30 days.
There is attemptdate in the folderprocessattempt which indicates when the assigned user updated the project(folder).................................................
1. Tables: Validuser, folderprocessattempt, folder, and folderprocess....................... ...
2. Validuser has userid, emailaddress ....................................................
3. Folderprocessattempt has attemptdate (shows when folder was last updated......................
4. Folder has foldertype, folderrsn, indate(indate is when the folder was created .................................................
What I want:......................................
1. Check the foldertype to get HJ folders................
2. Check assigneduser(email will be sent to assigneduser)
3. Check if assigneduser has more than 1 project of foldertype HJ and check if all the projects (HJ) for the user have been updated in the last 30 days...............
4. When email is sent, it should list the folderrsn for each folder that needs to be updated if the user has more than one folderrsn.
Message was edited by:
user644765 -
Date to Elapsed Days Conversion
Hello Guys
I need guidance in Date to Days Conversion
Lets Suppose i have a string as following
var time:String = "2009-09-01"
and as today is 5
so i want a value like
"4 Days Ago"
How could i convert this date to days?
Thanks in advanceHi,
First compare this with previous records, i think there is some wrong input, for this type of fiscal Period u can use PERI7 Conversion Routine.
http://help.sap.com/saphelp_nw04/helpdata/en/3f/e2e32d7e612d4eb4f610b2674af40b/content.htm
Hope it helps.
Regards
Siddhu
Maybe you are looking for
-
I need a code for below given problem. I have A custom table with the goals for certain jobs.which will be used as input for the Performance Screen creation. table format: Template ID Job Title Code Goal Type Criteria Goal Text 60003201
-
Set background color or image in Outlook Today view
Hello, I just started using the Outlook Today view in Outlook Data File and find it much easier to digest rather than scrolling through tons of folders for the 5 email accounts I have in it. However, the massive white background hurts my eyes, espec
-
Friends, So far we are not using Export LC's in our company... LC Application, LC opening are totally handled out of SAP. Special GL Indicator u201CLu201D has been created as Advance LC, 100% LC either in advance along with PO. Till GR and IR happen
-
JSAPI : Problems with the speech recognition HelloWorld example
I just started off with JSAPI. And I immediately ran into problems. These are the configurations and the stuff I did: My system: OS: WinXP JDK: JDK 6 Update 10 IDE: Netbeans 6.0 I downloaded the FreeTTS.zip from the FreeTTS site [http://freetts.sourc
-
Automatic update of cross references possible?
I work on a very long document using InDesign CS3 and InCopy CS3 and want to include cross references to other pages and chapters between the text. For example "Text...(See also chapter 3.4.1 on page 54)." I have the problem now that if I paste chapt