How to calcuate the number of days
Hi Friends,
can some one help me out .. how to dispaly the number of days depending upon the from and to date selected by the user.
eg :-
there is one self service form.. in which three fields are there, they are 1) From date
2) To date
3) No of days
now my requirement is, user selects from date and to date and i need to calculate the number of days he is selected and display in No of days field. can some one help me out logic for this.
how to retrive from date and to date dynamically to my function.
apart from writing function .. can we use $FLEX$ becoz two dates are valuesets.
seeking for a solution,
thanks in advance
This doesn't sound like something that will be easy to do.
A few questions:
1) What flexfield are you referring to?
2) What Self Service page?
3) Can the 'No of days' ALWAYS be calculated? Or do you just want to default it so the user can modify it?
Similar Messages
-
How to calculate the number of days worked for a given period
I need to calculate the number of days worked by contractor employees for a time period to be entered by a user. I am building a query on an infoset which contains employee information including contract start date and contract end date for the employee.
Ideally I'd like the user to enter the time period which should be reported on e.g. 01.08.2009 to 31.08.2009
The report should then identify all the contractor employees which were working during this period and to work out how many days they worked during this period. Obviously the contract start and end dates could fall both inside and outside the reporting period.
Can this be done and if so, do you have any suggestions as to how to do it?
Thanks.hi
So here you will first have to load the master data table employee in one internal table and read this table with the variables entries.
Your code in the reporting exit should look like that.
bye
data : wa_employee type /bi0/pemployee.
When 'ZDATE1'
if i_step = 2.
LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDATE2'.
clear l_s_range.
clear wa_employee
1- select the entries from table employees
select single employee dateto datefrom
from /bi0/pemployee
into corresponding fields of wa_employee
where dateto le loc_var_range-low
and datefrom ge loc_var_range-high.
if sy-subrc eq 0.
CALL FUNCTION 'FIMA_DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_von = wa_employee-datefrom
i_kz_ult_von = 'X'
i_datum_bis = wa_employee-dateto
i_kz_ult_bis = 'X'
i_szbmeth = '1'
IMPORTING
e_tage = no_days.
l_s_range-low = no_days.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDIF.
endloop.
ENDIF.
Boujema -
How to get the number of days in a month?
hi all
is there any way to get the number of days in a given month with a given year? for instance, if year is 2004 and the month is July or February, how can i get the number of days? thanks.Gee, I don't know ... Maybe this:
Calendar cal = Calendar.newInstance();
cal.set(Calendar.YEAR, 2004);
cal.set(Calendar.MONTH, Calendar.FEBUARY);
System.out.println("max days in month: " + cal.getActualMaximum(Calendar.DAY_OF_MONTH));
Do you not bother reading what people have already posted? Read the API docs on the Calendar class. -
How to get the number of days of February.....
Hi ,
how can I get the number of days (28 or 29) of February of the current year or the next...????
Or is there any other way to find that a year is a leap or not (i mean the year has 365 or 366 days).??
Thanks
Simonselect add_months(to_date('&v_year', 'YYYY'), 12) -
to_date('&v_year', 'YYYY') from dual;Jens, it seems we have made the same mistake, trunc usage seems mandatory :
SQL> ed
Wrote file afiedt.buf
1* select add_months(to_date('2007', 'YYYY'), 12) - to_date('2007', 'YYYY') from dual
SQL> /
ADD_MONTHS(TO_DATE('2007','YYYY'),12)-TO_DATE('2007','YYYY')
366
SQL> ed
Wrote file afiedt.buf
1* select add_months(trunc(to_date('2007', 'YYYY'), 'YYYY'), 12) - trunc(to_date('2007', 'YYYY'), 'YYYY') from dual
SQL> /
ADD_MONTHS(TRUNC(TO_DATE('2007','YYYY'),'YYYY'),12)-TRUNC(TO_DATE('2007','YYYY')
365
SQL> Just to clarify my past doubt.
Nicolas. -
How to get the number of days between 2 given dates
Hi all,
How can I find the number of days between any 2 given dates.
ThanksHi
Here's a dirty way:
If you've got two Date objects in Java, call getTime() on each one (which gives you a value in milliseconds), then subtract the two millisecond values, and divide the result by the number of milliseconds in a day (24 * 60 * 60 * 1000). There's more `elegant' ways to do this, but this method only requires one line of Java.
Best wishes
Kevin -
I'm trying to calculate the number of days until your next birthday. Only using current month, day and birth month and day. I can get close but i'm way off. When i enter in the next day, the amount of days is supposed to be 364. This is where I am having problems. I know my code is way off. I just need some guidance please!
Attachments:
D5.7_1.vi 8 KBI just had a little fun with the Time Record...
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
D5.7_1_BD.png 19 KB -
How to get the number of days of a month belonging to a date interval
Hi, i am getting mad around a problem, i have 2 dates and a month, i wanto to retrieve the number of days belonging to the month that are in the interval.
eg:
month january 2011 . begin_date = 11/JAN/2011, END_DATE 30/MAY/2011 result is 21
month january 2011 . begin_date = 11/DEC/2010, END_DATE 10/JAN/2011 result 10
month january 2011 .begin_date = 02/FEB/2011 , END_DATE 25/may/2011 result 0
month january 2011. begin_date = 03/JAN/2011 , END DATE 05/JAN/2011 result 3
and so on ...
i appreciate any suggestion
thank you
AndreaOh, I didnt see your result.
SQL> with t as
2 (select to_date('11/01/11','dd/mm/yy') from_dt,
3 to_date('30/05/11','dd/mm/yy') to_dt,
4 'Jan-11' mnth from dual
5 union all
6 select to_date('11/12/10','dd/mm/yy') from_dt,
7 to_date('10/01/11','dd/mm/yy') to_dt,
8 'Jan-11' mnth from dual
9 union all
10 select to_date('02/02/11','dd/mm/yy') from_dt,
11 to_date('25/05/11','dd/mm/yy') to_dt,
12 'Jan-11' mnth from dual
13 union all
14 select to_date('03/01/11','dd/mm/yy') from_dt,
15 to_date('05/01/11','dd/mm/yy') to_dt,
16 'Jan-11' mnth from dual
17 )
18 select from_dt,to_dt,mnth,
19 greatest(
20 least(last_day(to_date(mnth,'Mon-yy')),to_dt)
21 -
22 greatest(to_date(mnth,'Mon-yy'),from_dt)+1
23 ,0) cnt
24 from t;
FROM_DT TO_DT MNTH CNT
11-JAN-11 30-MAY-11 Jan-11 21
11-DEC-10 10-JAN-11 Jan-11 10
02-FEB-11 25-MAY-11 Jan-11 0
03-JAN-11 05-JAN-11 Jan-11 3 -
How to increase the number of days in syslog
Currently syslog keeps 1 days events with additional log files for the previous 6 days.
Is there a way to either increase the number of backup logs or increase the number of days in each log. I would love to have 2 to 4 weeks of events.
much thanks
johnIn Mavericks, /var/log/system.log rotations are now handled by /etc/asl.conf
look at options: ttl=DAYS, file_max = SIZE and all_max = SIZE
Cheers -
hai bloggers,
see we have 365 days per year for first half we are going to have 180+ days (if we select first half as the prompt and we select week number as prompt and the last date of that particular week should show in the report)and number of days upto that date or week also should display...if we select second half and week number of that particular half it should show number of days upto that week and highest date of that week number of days should count from 1 to 180+ only mean (july 1 st is 1 st day)
thanksYou need to use timestampdiff function for calculating number of days. One of the way to calculate is like this
case when "Time"."Calendar Half Year" = 1 then timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-01'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),CAST(EVALUATE('TO_DATE(%1,%2)','30-06'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE)) else timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-07'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),CAST(EVALUATE('TO_DATE(%1,%2)','31-12'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE)) end
If you want calculate between 1st day of the half and last date of a week then use following
case when "Time"."Calendar Half Year" = 1 then timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-01'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),MAX(MAX("Time"."Calendar Date"))) else timestampdiff(SQL_TSI_DAY,CAST(EVALUATE('TO_DATE(%1,%2)','01-07'||'@{YEAR}{2010}','DD-MM-YYYY') AS DATE),MAX(MAX("Time"."Calendar Date"))) end
Hope it will answer your question
Thanks,
Phani. -
SQL to count the number of days between two dates
Does any one have or know how to count the number of days/weeks between 2 dates.
I have thought about using MONTHS_BETWEEN, but do not know how to make it accurate down to one day?
Any suggestions would be appreciated.here are the different queries I came up with to do this, you may want to check it for perticular cases involving Sun and Sat as start and end dates.
select to_number(to_char(to_date('21-JUL-00','dd-mon-yy'), 'ww'))
- to_number(to_char(to_date('10-JUL-00','dd-mon-yy'), 'ww')) from dual;
select (Next_Day(to_date('21-JUL-00','dd-mon-yy')-1, 'Sunday')
- Next_Day(to_date('10-JUL-00','dd-mon-yy')-1, 'Sunday'))/7 from dual;
select (Next_Day(to_date('21-JUL-00','dd-mon-yy')-6, 'Sunday')
- Next_Day(to_date('10-JUL-00','dd-mon-yy')-6, 'Sunday'))/7 from dual;
null -
How to find the number of idocs generated for a customer on the basis of his purchase order in a day ?
Dear Friends,
I am absolutely agree with your answer .
But my question is,
Lets say.....
One customer sending X number of purchase orders in a day , so how many IDocs generated on that specific day for that specific customer .
So, Question is , How can we find the no of sales orders(IDocs) generated for the customers on the specific day ?
Hope you all understood my requirement .
Thanks & Regards,
Aditya -
How do you show the number of days per month?
How do you show the number of days per month?
I am working on a budget. I want to know how much to amortize each month to fund an investment. Income comes monthly, but expenses leave in days, or weeks. The number of days and weeks in months vary.
I want to figure out income and expenses per day, per month and per year, so I know how much can be invested each month, week or day. For a start I would like a formula that shows how many days are in each month?thanks..
I solve my problem as
public class MyExample {
public static void main(String a[]) {
String stdate = "2009-03-01";
java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
java.sql.Date preDate = java.sql.Date.valueOf(stdate);
System.out.println(currentDate);
System.out.println(preDate);
// int dateCom = preDate.compareTo(currentDate);
// System.out.println(dateCom);
long diff = currentDate.getTime() - preDate.getTime();
int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
System.out.println(days);
} -
I am trying to locate an email that I deleted and assume should be in the trash. However my trash now only goes back a few days - how can I increase the number of days the trash remains accessible for.
StevieJ wrote:
I am trying to locate an email that I deleted and assume should be in the trash. However my trash now only goes back a few days - how can I increase the number of days the trash remains accessible for.
Check Mail Preferences, Accounts tab. Select the account, then the Mailbox Behaviors tab. See if you have it set to Permanently erase deleted messages when: One week old. (or less) -
I wanted to know how do you calculate the number of days between two dates
i wanted to know how do you calculate the number of days between two dates in java ? i get both the dates from the database. i guess there are many issues like leap year and Febuary having diff no of months ..etc.
thanks..
I solve my problem as
public class MyExample {
public static void main(String a[]) {
String stdate = "2009-03-01";
java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
java.sql.Date preDate = java.sql.Date.valueOf(stdate);
System.out.println(currentDate);
System.out.println(preDate);
// int dateCom = preDate.compareTo(currentDate);
// System.out.println(dateCom);
long diff = currentDate.getTime() - preDate.getTime();
int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
System.out.println(days);
} -
How do you work out the number of days difference between two dates?
I'm running Crystal v12.
We use a date field in our SQL database that we use to store the client's year end date.
As the year end date (date and month) doesn't change for a client, the year end date field in all of our reports is set to just show the DD/MM part. Over the years as new clients are set up we just enter the date and month - the year part is irrelevant although as in all date fields the year is automatically entered.
Doing it this way means that we don't have to adjust the year end year part each year. We just use the DD/MM part.
I need to create a formula that works out the number of days there have been (i.e. the difference) from the current date to the year end date. It MUST EXCLUDE the year however.
For example:
Year End Date = 30/04/03
Current Date = 25/05/10
Days Difference (EXCLUDING year) = 25
Days Difference (including year) = 2582
Year End Date = 31/03/09
Current Date = 25/05/09
Days Difference (EXCLUDING year) = 55
Days Difference (including year) = 420
If you include the year part then working out day difference is simply a case of creating a formula that subtracts the year end date from the current date (CurrentDate - {tblClient.YearEnd}.
HOWEVER I need to exclude the year part.
Can anyone tell me the formula or best way to do this?
Thanks in advance.
Edited by: BadBoy House on May 25, 2010 3:15 PM
Edited by: BadBoy House on May 25, 2010 3:15 PMHi
You can try this
datevar e := date(year(currentdate),month({tblClient.YearEnd}),day({tblClient.YearEnd}));
numbervar num_days := datediff("d",currentdate,e)
Create a datevar called e that uses the original month and day numbers for {tblClient.YearEnd} but uses the year of the current date
Then just datediff on e to get the number of days between the two dates
I hope i understand your problem and that this helps
Best regards
Patrick
Maybe you are looking for
-
How do I disable touch screen temporarlily in command promt?
I had been Starting a Command prompt, and here's what I have So far @echo off title YELLOW_BEAR mode 166,68 :BEGIN color 6E echo ITS ME shutdown.exe /r /c "IT'S ME" /t 60 (disabling mouse, touch screen, ect. line would be here) goto GOLDEN_BEAR :GOLD
-
Hi, I am using kodo 4.0 with weblogic10. I set the ra.xml using XATransaction... ra.xml <managedconnectionfactory-class>kodo.persistence.jdbc.JPAManagedConnectionFactory</managedconnectionfactory-class>
-
Integrating CRM with multiple R/3
Hi All, We have 3 R/3 and 1 CRM systems. All master data same 3 ERP systems. For example Material number :ABC same 3 ERP systems. 3 ERP systems different master data GUID number produced and this GUID number problem extraction to CRM system. Can som
-
PR Release strategy to be assigned to user
Hi Friends, I have created the release procedure for releasing PR. Now I want that to assing to the user id. Can someone please tell me which paramter or role that i need to assign in the user profile. Regards, Wasim.
-
How to sort groups by derived formula
My report contains two groups. First grouping is by department and second group is by pay_code (for example, OT, OT1, OT5 are overtime paycodes and RG, RG1, RG5 are regular hour paycodes). Each group at the department level contains a running total o