Function Module to get the difference between two times.
Hi All,
I want to know if there is any function module that gives me the difference between two specified times.
For Ex: Time 1: 12/01/2007 00:01 A.M
Time 2: Time 1 - 180 Seconds. This changes the time, also may even change the Date. (As in above situation, the Time 2 will be 11/30/2007 11:58 P.M)
Could some one please suggest if there is any function module for this case.
Thanks in Advance.
Hi, You can use the following function module to calculate the diffrence between to dates in the unit that you want.
COPF_DETERMINE_DURATION calculates the difference between two dates and time in minutes and hours.
Parameters:
EXPORTING
I_START_DATE "The start date of the time interval
I_START_TIME "The start time of the time interval
I_END_DATE "The end date of the time interval
I_END_TIME "The end time of the time interval
I_UNIT_OF_DURATION "Time unit of the duration if not to be calculated in days.
Value ===== Meaning
' ' ===== Day (default)
D ===== Days
H ===== Hours
MIN ===== Minutes
MON ===== Months
S ===== Seconds
WK ===== Weeks
YR ===== Years
I_FACTORY_CALENDER "A factory calender if not using the Gregorian calender
IMPORTING
E_DURATION "Time difference in unit specified.
Message was edited by:
Rajesh Soman
Similar Messages
-
Function Module to find the Difference between two times.
Hi All,
Wud you plz let me know the Function Module to find the Difference between two times.
Input Time1( Hours:Minutes) Time2 ( Hours:Minutes)
Need Output in Hours:Minutes only . ( No seconds Needed )
Ex :
Input :
06:00 to 18:00 Output : 12:00
and 20:00 to 06:00 Output: 10:00 with +ve sign only. No -ve sign.
Thanks,
N.L.Narayanacheck this .
data : p_timel like sy-uzeit,
p_timeh like sy-uzeit,
diff like sy-uzeit,
di(8) type c .
p_timel = '200000'.
p_timeh = '060000'.
diff = p_timeh - p_timel.
concatenate diff+0(2) ':' diff+2(2) into di.
write:/ di.
also check for this.
p_timel = '060000'.
p_timeh = '180000'.
see if this can be implemented in ur code .
or else u can try with Fm L_TO_TIME_DIFF passing startdate enddate starttime endtime with UOM as MIN
hope this helps regards,
vijay -
Function module to get the difference of dates ..
Hi ,
Can somebody pls help me with the function module to get the difference between two dates?
I need to find the difference value and delete records if >1.
Thanks in advance.
Regds,
Leeza.Leeza,
When I tested the FM in my Program, it is <b>working</b>!!!!!
Note that the Two Input Dates are to be in the format of <b>DATS</b> type (Eg: <b>vimimv-dmibeg</b>).
U can want the Day which u have specified in the parameter I_DATUM_BIS (eg: 20050101) to be included for
the calculation , then put X in the parameter I_KZ_INCL_BIS.
Sample Code :
report zkam01.
data:
<b>sav_nlaufz like rf60v-nlaufz,
date1 type vimimv-dmibeg,
date2 type vimimv-dmiend.</b>
date1 = '20050101'.
date2 = '20051001'.
call function 'MONTHS_BETWEEN_TWO_DATES'
exporting
i_datum_von = date1
i_datum_bis = date2
i_kz_incl_bis = 'X'
importing
e_monate = sav_nlaufz.
write:
date1,
/ date2,
/ sav_nlaufz.
Please allot points if the problem is solved.
Thanks
Kam
Message was edited by: Kam -
Function Module to find the Diff bt Two Times : O/p : Hours:Minutes only
Hi All,
Wud you plz let me know the Function Module to find the Difference between two times.
Input Time1( Hours:Minutes:Seconds) Time2 ( Hours:Minutes:Seconds)
Need Output in Hours:Minutes only . ( No seconds Needed )
Thanks,
N.L.NarayanaHi
Please use FM
<b>SD_DATETIME_DIFFERENCE</b> -
How to get the difference between two columns in a column group
Hi All,
My first time here and really new to programming. I would like to get the difference between 2 columns that are inside
a column group.
Here is my sample table below: The Column Group is PeriodNumber and can only choose 2. like 1 and 2.. I would like to have a third row which will simply calculate the difference between the amounts in PeriodNumber 1 and 2.
PeriodNumber
Account 1 2
1) Cash 10,000 15,000
2) Receivables 12,000 11,500
3) Equipment 5,000 5,500
Total Assets 27,000 32,000Hi yabgestopa,
From your description, you want to get the difference between two columns in a column group. After testing it in my environment, we can use custom code to achieve your requirement. For more details, you can refer to the following steps:
Copy the custom code below and paste it to your report. (Right-click report>Report Properties>Code)
Dim Shared Num1 As Integer
Dim shared Num2 As Integer
Public Function GetAmount(Amount as Integer, Type as String)
If Type = "1" Then
Num1=Amount
Else
Num2=Amount
End If
Return Amount
End Function
Public Function GetDif()
Return Num1-Num2
End function
Right-click the second column to insert a third column with Outside Group-Right.
Then use the expressions below in the matrix.
=Code.GetAmount(Fields!Amount.Value,Fields!PeriodNumber.Value)
=code.GetAmount(Sum(Fields!Amount.Value),Fields!PeriodNumber.Value)
=Code.GetDif()
The report looks like below.
If you have any questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Java code to get the difference between two dates in days
Hi ppl,
I need to write a user defined function to get the difference between two date nodes, in days.Please help me out
regards,
PrashanthHi,
have a look at those two:
(How do I calculate the difference between two dates?)
http://joda-time.sourceforge.net/faq.html
Calculating the Difference Between Two Datetime Stamps
http://www.xmission.com/~goodhill/dates/deltaDates.html
Get difference in days
http://javaalmanac.com/egs/java.util/CompDates.html
Regards,
michal -
X6 = "1/5/15 5:16 AM" & NOW ....................difference by Only Time
not date
X6 date and Time will be changing, Its not Constant
Dim myDateTime As DateTime = X6
Dim myDate As String = myDateTime.ToString("dd/MM/yy")
Dim myTime As String = myDateTime.ToString("hh:mm tt")
Dim myDateTime1 As DateTime = Now
Dim myDate1 As String = myDateTime1.ToString("dd/MM/yy")
Dim myTime1 As String = myDateTime1.ToString("hh:mm tt")
Need to use this function to find the Difference between Two Time. due to 12:00 AM isuue
Function XLMod(a, b)
' This replicates the Excel MOD function
XLMod = a - b * Int(a / b)
End Function
Output Required
dim dd = XLMod(myTime - myTime1)
Problem is myTime & myTime1 is String Need to convert them into Time, Later use XLMOD Funtion.Induhar,
As an addendum to this, I thought I'd add this in also: If you have two valid DateTime objects you might consider using a class which I put together a few years ago
shown on a page of my website here.
To use it, just instantiate with two DateTime objects (order doesn't matter, it'll figure it out) and you'll then have access to the public properties. For this example, I'm just showing the .ToString method:
Option Strict On
Option Explicit On
Option Infer Off
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim date1 As DateTime = Now
Dim date2 As DateTime = #1/1/1970 2:35:00 PM#
Dim howOld As New Age(date1, date2)
MessageBox.Show(howOld.ToString, "Age")
Stop
End Sub
End Class
I hope that helps, if not now then maybe at some point in the future. :)
Still lost in code, just at a little higher level.
Thanx frank, can use this in Future.... -
How to get the difference between two date
Hello,
I want to know how to write a code the tell me the difference between two date, I am using
oracle.jbo.domain.Date
i have a rent date and return date so my code is
Date rent=(Date)nr.getAttrbute("RentDate"),ret=(Date)nr.getAttrbute("ReturnDate");
is there a way to know the difference in days between those two dates ?
Thankshi,
try this.....
DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy");
Date date = (Date)formatter.parse(dateStr); //// dateStr <- from date value (that is string value)
Date dateto = (Date)formatter.parse(datetostr); //// datetostr <- to date value (to date getting from as a string)
Calendar cal = Calendar.getInstance();
cal.setTime(date);
Calendar calto = Calendar.getInstance();
calto.setTime(dateto);
fromDate = cal.get(Calendar.DATE) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR);
toDate = calto.get(Calendar.DATE) + "/" + (calto.get(Calendar.MONTH) + 1) + "/" + calto.get(Calendar.YEAR);
// System.out.println("from Date : " + fromDate);
if ((fromDate != null && toDate != null) && (date.compareTo(dateto) > -1) ) {
fc.addMessage("VacationQueryComponent", new FacesMessage(FacesMessage.SEVERITY_ERROR, "From Date cannot be lower than To Date", "From Date cannot be lower than To Date"));
fc.renderResponse();
thks. -
Trying to Get the "Difference" Between Two Tracks
What I am trying to accomplish is this: I have an audio track of a voiceover with a music bed beneath it. I also have the bed music by itsself, without the voiceover. I want only the voice portion. Is there a way that I can "cancel out" the music portion or get the difference between the two tracks (just the voice portion)? It seems that there should be some means of doing this, but for the life of me I cannot figure out how to do it!
Any advice?If it's exactly the same music track, then as long as you line it up sample-accurate and the levels co-incide, you can do a simple subtractive process. You need both files available, trimmed to length. Open them both in Edit View, and copy one of them to the clipboard. Open the other, and select Mix-paste, and use the 'invert' option. That will effectively subtract one from the other, with the difference being your vocal.
Have to tell you though that the chances of getting this spot on are amazingly low... any errors at all leave you with bleed-through, about which you can do nothing. -
How to get the difference between two HashMaps
i have two HashMaps
HashMap first = new HashMap<Integer,Object>();
HashMap second = new HashMap<Integer,Object>();
How to get the difference between one and two and put the result in the third
HashMap third = new HashMap<Integer,Object>();My bad, difference of course means removeAll():Map<Integer,Object> first = new HashMap<Integer,Object>();
Map<Integer,Object> second = new HashMap<Integer,Object>();
Map<Integer,Object> third = new HashMap<Integer, Object>(first);
third.keySet().removeAll(second.keySet());No loops needed. -
Need to get the difference between two period
Hi All,
I need to get the difference of two posting period like period is in format YYYYMM.
I need to subtract posting perid '200512' FROM '200601' how will be it possible.
Please suggest.
Thanks,
SandyHi,
YOu can also do like the following.
Determine you first day of first period and last day of second period.
data: first_day type datum,
last_day type datum,
days type i.
first_day = date from FM RKE_GET_FIRST_DAY_IN_PERIOD
last_day = date from FM RKE_GET_LAST_DAY_IN_PERIOD
days = last_day-first_day.
Thanks,
Ramakrishna -
How to get the difference between two BufferedImages?
All the BufferedImage which is grabbed from AWT may be same each other,
i only want to get the different part of two continuous BufferedImages and send ti over internet.
I have compared two BufferedImages by RGB (int[]), but this process wastes 400~500ms,it's terrible,:)
who has any good idea about this?
thanks
Best Wishes
mauvespanthanks ! cary ,
I have a list contained some BufferedImages gotten from AWT component,and then these images
will be transfered to client and displayed in Internet explore ,actually there are only some difference
between two continuous BufferedImages,i don't want to transfer the WHOLE image to client,SO i
want to handler every image before sending to client , at last, the different part will only be sent to client.
All these ideas will be contained this method:
* Compare the specified two BufferedImages and return the different part between them.
* @param ref the specified first image
* @param gen the specified sencond image
* @return the different part between the specified two images.
public static void BufferedImage compareBufferedImage(BufferedImage ref,BufferedImage gen){
to finish this method ,do you have any good ideas?or sample code?
thanks
Best wishes
mauvespan -
I have a database table where it keeps record of the transaction when it starts at StartTime and when it ends at EndTime. Both these entries are having the timestamp entries. Say for example, I have a tuple with Entries like 'Transaction A' starts at '2014-05-07
20:55:03.170' and ends at '2014-05-08 08:56:03.170'. I need to find the difference between these two timestamps and my expected output is 12:01:00.000. Let me know how to achieve this ?Hi,
You can use below script which calculates difference as DD:HH:MM:SS. You can modify the same:
DECLARE @startTime DATETIME
DECLARE @endTime DATETIME
SET @startTime = '2013-11-05 12:20:35'
SET @endTime = '2013-11-10 01:22:30'
SELECT [DD:HH:MM:SS] =
CAST((DATEDIFF(HOUR, @startTime, @endTime) / 24) AS VARCHAR)
+ ':' +
CAST((DATEDIFF(HOUR, @startTime, @endTime) % 24) AS VARCHAR)
+ ':' +
CASE WHEN DATEPART(SECOND, @endTime) >= DATEPART(SECOND, @startTime)
THEN CAST((DATEDIFF(MINUTE, @startTime, @endTime) % 60) AS VARCHAR)
ELSE
CAST((DATEDIFF(MINUTE, DATEADD(MINUTE, -1, @endTime), @endTime) % 60)
AS VARCHAR)
END
+ ':' + CAST((DATEDIFF(SECOND, @startTime, @endTime) % 60) AS VARCHAR),
[StringFormat] =
CAST((DATEDIFF(HOUR , @startTime, @endTime) / 24) AS VARCHAR) +
' Days ' +
CAST((DATEDIFF(HOUR , @startTime, @endTime) % 24) AS VARCHAR) +
' Hours ' +
CASE WHEN DATEPART(SECOND, @endTime) >= DATEPART(SECOND, @startTime)
THEN CAST((DATEDIFF(MINUTE, @startTime, @endTime) % 60) AS VARCHAR)
ELSE
CAST((DATEDIFF(MINUTE, DATEADD(MINUTE, -1, @endTime), @endTime) % 60)
AS VARCHAR)
END +
' Minutes ' +
CAST((DATEDIFF(SECOND, @startTime, @endTime) % 60) AS VARCHAR) +
' Seconds '
Reference:
http://sqlandme.com/2013/12/23/sql-server-calculating-elapsed-time-from-datetime/
- Vishal
SqlAndMe.com -
Help I need to subtract times to find the difference between two times?
Hello there, I really need help.
I'm trying to make this attendance tracking system so that when a user enters his or her ID the system wll remember his/her check in time. However I also need to find out either how late the person is or how early to store their over time and late.
So I get the time by using a timestamp, so I'm left with a timestamp that I store into the db. But the problem comes when trying to compute for the late or over time. To do that I have to get the normal login/checkin time from the employee schedules table in the db and either subtract that time from the checkInTime to compute for how late or subtract the checkIn time from it to find early.
The thing is, the schedule is stored in datetime format in the db since the db is sql. Also I have no idea on how to subtract the two dates via java. The month, date and year stored in the sql db are just fillers, all I need computed is the time difference of the hours and minutes between the checkInTime and the schedule.
I've tried to use datediff: SELECT e.employeeNumber, datediff('hh', startTime, checkInTime) as lateTime from employeeschedules e, timandattendance, contractualemployees c where c.scheduleNumber=e.scheduleNumber and t.employeeNumber=c.employeeNumber and t.checkInNumber=1;
But it keeps on giving out various errors: You have an error in your sql syntax check your manual that corresponds to your sql server version. for the right syntax to use near , checkInTime) as lateTime from employeeschedules e, timandattendance, contractualemployees c where c.scheduleNumber=e.scheduleNumber and t.employeeNumber=c.employeeNumber and t.checkInNumber=1;
My sql server is My SQL 5.0.5
Now I'm thinking of useing Gregorian instead, but I don't know how to use Gregorian and dont know the various methods. Can someone tell me what to do, provide some sample codes and references that I can use to accomplish what I need to do?NewtonsApple_2 wrote:
Now I'm thinking of useing Gregorian instead, but I don't know how to use Gregorian and dont know the various methods. Can someone tell me what to do, provide some sample codes and references that I can use to accomplish what I need to do?it may help...
GregorianCalendar -
How to do find the difference between two time stamps
Hi all,
i have a table with 2 columns called GMT time and Local time . so i need to find difference between these two time stamps.
i tried like this
select to_date(GMT_TIME,'yyyy-mm-dd hh24:hi:ss')-to_date(LOCAL_TIME,'yyyy-mm-dd hh24:hi:ss') from date_table
the result is coming as follows ..
0.291666666667
i did not under stand the out put.
In my table GMT_TIME= 2011-06-26 00:00:00 and LOCAL_TIME=2011-06-25 17:00:00 ..
please help me how to get exact hours between two dates ..
Thanks
SreedharHi Sreedhar,
Your output (0.2916666) has the unit day.
You should multiply with 24 to get the unit hour.
select ( to_date(GMT_TIME,'yyyy-mm-dd hh24:hi:ss')-to_date(LOCAL_TIME,'yyyy-mm-dd hh24:hi:ss') ) * 24 from date_table;Rgds,
Tycho
Maybe you are looking for
-
Can anyone help me change the DOB on my sons profile for his apple I'd so I can setup family sharing? I originally put both ids in my name. He is 19 do it keeps saying needs my permission but no instructions in how to get that done? His phone was sto
-
XSL transformation exception when using it in a subprocess
Hi all I want to use a service task in sub-process that call a function with ref_cursor return type, when i map data association from output parameters to data object with xsl transformation an exception raise. in other hand my sub-process properties
-
Satellite Pro 6070 Slim Select Bay Drive won't regonize CDs
I have a problem with my Slim Select Bay DVD drive. The disc motor is running and the laser unit is moving, but it won't recognize any disc until I flip the whole notebook on the right side. Then after a few attempts with opening and closing the driv
-
Amd catalyst control center panel
am trying to use the AMD Catalyst Control Center but if you look at picture u will see that most of the functions of the control center are missing. I have tried reinstalling it ( the one on the HP download page) but it says "the computer does not me
-
How do i resolve error (-50) i cannot download a rental
I rented a movie from i tunes. it stopped loading on its own and everytime i attempt to restart an error window pops up, an unknow error occured (-50). i would like to know how to fix this or get my money back