Difference of Time Field in Seconds
Hello Experts,
I have Created two UDFs of Start Time & End Time on Production Order With Type Hour as SAP Supports now i want difference between End Time & Start Time in Seconds
Please Suggest Query....
Regards,
Bhavank
Hi GordonDu
Thanks for your reply
I have created UDF with Type Hour Where we can enter Time in Hour Format, In my case i have created two UDF with Hour Type Start Time & End Time where i am entering Production Start Time & End Time now i want Difference Between Those two Fields in Seconds
For Example Start Time = 09:00 AM
End Time = 18:10 PM
Then i Want difference End Time - Start Time in Seconds
If you have any other Solution for taking Time Difference then Please Suggest me
Regards,
Bhavank
Similar Messages
-
Have trouble creating formula using FormCalc that will calculate difference in time (hours and minutes) from a Start Date/Time field and End Date/Time field.
I am using to automatically calculate total time in hours and minutes only of an equipment outage based on a user entered start date and time and end date and time.
For example a user enters start date/time of an equipment outage as 14-Oct-12 08:12 AM and then enters an end date/time of the outage of 15-Oct-12 01:48 PM. I need a return that automatically calculates total time in hours and minutes of the equipment outage.
Thanks ChrisHi,
In JavaScript you could do something like;
var DateTimeRegex = /(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d)/;
var d1 = DateTimeRegex.exec(DateTimeField1.rawValue);
if (d1 !== null)
var fromDate = new Date(d1[1], d1[2]-1, d1[3], d1[4], d1[5]);
var d2 = DateTimeRegex.exec(DateTimeField2.rawValue);
if (d2 !== null)
var toDate = new Date(d2[1], d2[2]-1, d2[3], d2[4], d2[5]);
const millisecondsPerMinute = 1000 * 60;
const millisecondsPerHour = millisecondsPerMinute * 60;
const millisecondsPerDay = millisecondsPerHour * 24;
var interval = toDate.getTime() - fromDate.getTime();
var days = Math.floor(interval / millisecondsPerDay );
interval = interval - (days * millisecondsPerDay );
var hours = Math.floor(interval / millisecondsPerHour );
interval = interval - (hours * millisecondsPerHour );
var minutes = Math.floor(interval / millisecondsPerMinute );
console.println(days + " days, " + hours + " hours, " + minutes + " minutes");
This assumes that the values in DateTimeField1 and DateTimeField2 are valid, which means the rawValue will be in a format like 2009-03-15T18:15
Regards
Bruce -
Find datetime difference between two fields and add the difference to the current datetime.
Hi all,
First I need to find the difference between the two date times fields (D1 and D2) and than add the diffence between them to the curent datetime to generate new datetime field (D3).
D1
D2
2013-05-09 12:12:57.000 2013-05-09 12:12:57.000
2013-05-10 12:12:57.000 2013-05-09 5:10:01.000
2013-05-09 9:13:27.000 2013-05-11 11:00:21.000
Thanks!Hey,
You can try this
SELECT DATEDIFF(Day, D1, D2) as Date_Diff from Table_3
Replace day with
other units you want to get the difference in, like second, minute etc. -
I want to do calculation between date/time fields
Post Author: fmonsma
CA Forum: Publishing
Hi, I already post this question a couple of times but I can't make it work.
IST:I have converted a date/time field to a field so i can make calculation on it but i don't know ho to convert it to minuts;seconds.
Starttime - Endtime - Convert begin - Convertend - convertsumbegin - convertsumend - difference between31-7 12:39:00 - 31-07 13:08:00 - 123900 - 010800 - 123.900 - 10.800 - -113.100
SOLL
Start time - Endtime - Differencebetween12:39 - 13:08 - 0:29
If i make this calculation in Excel it's very simple and works perfect. I want this in my Webintelligence report but don't know which functions/script i need to have. Thanks;Post Author: jsanzone
CA Forum: Publishing
fmonsma:
Based on the sample data that you provide, it appears that you want to be able to report data based on the number of minutes that have elapsed between "Starttime" and "Endtime". Looking at the WebI Variable Editor functions in the "Date & Time" functions list, it does not appear that there are any capability to determine elapsed minutes (it appears that the only "time" of the "Date & Time" functions is the "CurrentTime" function, not much else in regards to time...)
You don't mention the database platform you are using, however, if you happen to be using MS SQL Server, then they have the DATEDIFF function. Within DATEDIFF the parameters are: DATEDIFF ( datepart , startdate , enddate ), where datepart specificies any of the following facts: Year, quarter, Month, dayofyear, Day, Week, Hour, minute, second, millisecond
Bottom line, you will most likely not be able to rely on WebI to determine the elapsed seconds and you'll have to set up an object within your Universe to do the work on the database server and bring it across to your reports that way. -
Rounding time field to nearest half hour
Post Author: fiscyn
CA Forum: Formula
Is there a way to round a time field?
For example, if a time field is from 9:01 to 9:14 I want it to round back to 9:00;
9:15 to 9:29 or 9:31 to 9:44 I want either option to round to 9:30
and 9:45 to 9:59 I want to round to 10:00.
I want to keep the original time and have the rounded time listed next to it. Also I want this for a 24 hour clock, military time. Don't know if that makes a difference.
Any help is appreciated.
Thanks.Post Author: fiscyn
CA Forum: Formula
I'm slowly getting this to work. Just a couple problems, minor I hope.
I used the CTime function and used the rounding formulas for minutes and hours as you suggested. It works great. But the results for the hours come out as 12.00 and the minutes as 30.00 or 0.00. How do I drop the decimals? I tried the totext, 0 function, but the numbers don't line up correctly. If the hour is 9.00, it drops the zero place holder. So if 9 and 10 are lined up, the 9 is above the 1 instead of the 0.
It works fine for the minutes except I end up with 0 instead of 00. Any suggestions?
I greatly appreciate the help so far. Thank you. -
Function module to add 2 time fields
I've 2 time fields : t1 = 06:00:00 (start time)
t2 = 06:00:00 (end time)
t3 = 01:30:00 (break time)
it's basically : t1 + t2 - t3.
the result should be : 21:30:00Hi Narsingh,
Do like this :
tables : syst .
parameters : time1 like syst-uzeit ,
time2 like syst-uzeit .
data : time3 TYPE STRING ,time4 TYPE STRING,time5 TYPE STRING.
time4 = time1 .
time5 = time2 .
time3 = time4 + time5 .
write /(10) time3 USING EDIT MASK'__:__:__'
or converting the time in seconds, and then adding all the time in seconds and then converting it back to hrs and mins as required....
best regards
Himayat -
DateDiff Help (Need time difference FROM Time 1 TO Time 2 - one direction)
I hope I am putting this in the right section. This is my first post. Thank you all ahead of time for your help.
I am new to both SQL and Report Builder so please bear with me and thank you ahead of time.
I need to find the time difference (in minutes) between Time 1 and Time 2. I've figured out the basics in how to do this but I need the logic to work in ONE DIRECTION. Meaning I need the statement to find the difference STARTING FROM TIME 1 and then ENDING
WITH TIME 2. I need the statement to always assume that Time 1 is FIRST and that Time 2 is LAST.
Here's an example of my results now with a basic DateDiff statement.
Time 1 | Time 2 | Time Difference (in minutes)
11:30 | 1/15/2015 11:50:00 AM | 20
23:50 | 1/15/2015 12:00:00 AM | 1430
23:45 | 1/15/2014 2:05:00 AM | 1300
Please note that Time 1 does NOT have a date at all and came over from its table as a simple 4 digit string so I had to convert it to datetime format using a concatenate statement. If it DID have a date then this probably wouldn't be a problem.
Thoughts?
Thanks.Thanks, Patrick. I'll look into understanding that (I'm still new to both SQL and Report Builder). Could you explain to me what it does?
I was able to answer my own question only to find that it didn't quite work the way I need it to. I was able to make the logic work so that "if the time is 12AM then change the date for Time 1". However, I ran into another problem and realize that
I ultimately just need to get this to work in one direction. Meaning I need it to find the difference in time STARTING from the Time 1 field TO the Time 2 field. Here's why (using the statement I got to work but only for 12AM):
Time 1 | Time 2 | Time Difference (in minutes)
23:45 | 1/15/2014 2:05:00 AM | -1300 -
Mapping time field issue!
Hi,
i have a time field in R/3 which is of length 4 ( numc ).
and in BW side it was decided to be a key figure. so i had created a key figure of type time.
( as i heard key figure time type has length 8 )
is there any problem if i could map these two fields in transfer rules!
Thanks,
RaviHi,
Assuming your R/3 field is hhmm
it will depend what you have chosen in the data type of your key figure:
- if TIMS you'll have to add two 00 at the end of your field.
Routine: CONCATENATE TRAN_STRUCTURE '00' INTO RESULT.
I don't think you will be able to calculate times in queries with this one.
if DEC: then it represent the number of seconds between 0 and your value.
You'll have then to write the code:
DATA: lt TYPE TIMS.
CONCATENATE TRAN_STRUCTURE '00' INTO lt.
MOVE lt TO RESULT. "ABAP will calculate the number of seconds accordingly
hope this helps...
Olivier. -
Time field also displaying current date
Hi there
I have two databound fields (to a Sybase back-end) - one is a date field, the other a time field!
The date field works fine, but the time field is displaying the current date as well as the data retrieved time!
The field is set to:-
Data pattern: HH:MM::SS
Data Format: Time
Type: Date/Time Field
Validation Pattern: HH:MM:SS
The field is defined as 'time' in Sybase, and displays just the time in other objects (.NET fields...).
Anyone any ideas?not the cleanest code, but i had this laying around in an old
project...
date = new Date()
month = date.getMonth() + 1
today = date.getDate()
fyear = date.getFullYear()
hours = date.getHours()
minutes = date.getMinutes()
seconds = date.getSeconds()
if(month <10){
month = "0"+month
if(today<10){
today = "0"+today
if(hours <10){
hours = "0"+hours
if(minutes <10){
minutes = "0"+minutes
if(seconds <10){
seconds = "0"+seconds
CurrentTime.text = month+"/"+today+"/"+fyear+"
"+hours+":"+minutes+":"+seconds -
Hi,
I have 2 date fields in my form, which should display the date in differnt format. (yyyy.mm.dd / dd-mm-yyyy)
To get the current date I use java script only
Formular1.p1.date_YYYYmmDD::initialize - (JavaScript, client)
var date = new Date();
this.rawValue = date.toLocaleDateString();
My first problem is (red): I get date in English, but I want it in a different language. As it was set in form settings
My second issue is: how can I format a date/time-filed (not a text field) in javascript with a specific pattern on init-event?
It seems my code in init-event overrides the pattern configuration of the date/time-field
Here is my form, if anyone want to check it:
https://acrobat.com/#d=zeOMyj9MhBdYbVWk8S1pHwHi,
I think both problems are the same, when setting a date/time field using the rawValue the format always has to be yyyy-mm-dd, if you use any other format the value is just treated as text and displayed without formatting.
var date = new Date();
this.rawValue = util.printd("yyyy-mm-dd", date);
You can also set the formattedValue if you have a date in the correct format.
var date = new Date();
var currentLocale = xfa.resolveNode("#localeSet.#locale").name;
var dateFormat = "date("+currentLocale+"){DD MMM, YYYY}"
this.formattedValue = util.printd(dateFormat, date, true)
This code assumes the display pattern is date{DD MMM, YYYY}
The date format specification is in the XFA Spec http://partners.adobe.com/public/developer/xml/index_arch.html
Regards
Bruce -
Getting time interval in seconds
How do I get the time interval between two date ( i.e to_date - from_date) in seconds ? The date range can span across several days , even months . I need to order the rows according to this interval, hence able to get the difference in seconds will help.
This information can be useful for you :
MONTHS_BETWEEN returns number of months between dates date1 and date2. If date1 is later than date2, then the result is positive. If date1 is earlier than date2, then the result is negative. If date1 and date2 are either the same days of the month or both last days of months, then the result is always an integer. Otherwise Oracle calculates the fractional portion of the result based on a 31-day month and considers the difference in time components date1 and date2.
Examples
The following example calculates the months between two dates:
SELECT MONTHS_BETWEEN
(TO_DATE('02-02-1995','MM-DD-YYYY'),
TO_DATE('01-01-1995','MM-DD-YYYY') ) "Months"
FROM DUAL;
Months
1.03225806
Joel P�rez -
How to get accumulated time field not actual time
Hello-
I have a field in a table as "time" however the time data is actually accumulated time over a period of a month not an actual time. So for example. We re reporting on Inbound and Outbound phone call duration per employee so we have:
Inbound Duration: 71:45:52 (this is accumlated time, meaning 71 hrs, 45 min, 52 seconds) but when it is displayed in excel or crystal it shows as:
1/2/1900 11:45:52 PM in excel. I
f you look at the format in excel it should be correct set in the number tab like: custom [h]:mm:ss
In the actual cell itself it shows the 71:45:52 but in the display that is where it shows the other 1/2/1900 11:45:52 PM
11:45:52 in crystal since it's just a time field in the table
Does anyone know how to correct this on either excel side or crystal? We have our data in excel which we import into a table to use crystal reports on.
thanksMy formulas were assuming the data was coming in as a datetime value, as it was in your original post. (Jason was typing his reply while I was typing mine...) So, the formula with accumulation is (BASIC SYNTAX - make sure the formula editor has this selected, not Crystal Syntax):
global secAccum as number
dim sec as number
dim min as number
dim hr as number
sec = DateDiff("s", CDateTime(1900,1,1,0,0,0), {csr_phones.duration})
secAccum = secAccum + sec
min = int(sec / 60)
hr = int(min / 60)
sec = sec - (min * 60)
min = min - (hr * 60)
formula = cstr(hr, "0") + ":" + cstr(min, "00") + ":" + cstr(sec,"00")
And to show the accumulated seconds:
WhilePrintingRecords
global secAccum as number
dim sec as number
dim min as number
dim hr as number
sec = secAccum
min = int(sec / 60)
hr = int(min / 60)
sec = sec - (min * 60)
min = min - (hr * 60)
formula = cstr(hr, "0") + ":" + cstr(min, "00") + ":" + cstr(sec,"00")
HTH,
Carl -
How to find difference btw time?
hi,
Can any one tell me are there any function modules to perform add, diff(minus) operation on time fields?
please let me know if you know any.
thanks in advance,
Prasad Babu.Hi,
Try <b>CCU_TIMESTAMP_DIFFERENCE</b>
CALL FUNCTION 'CCU_TIMESTAMP_DIFFERENCE'
EXPORTING
timestamp1 = timestamp1
timestamp2 = timestamp2
IMPORTING
difference = diff
EXCEPTIONS
OTHERS = 1.
http://sap.ittoolbox.com/groups/technical-functional/sap-r3-dev/f-module-for-dates-subtraction-124376#
Check out these threads
date time difference
FM to Difference between two data and time in tims data type
Regards,
Santosh -
Difference between Information Field and Application Field
Hi,
Can anyone tell me the difference between information field and application field in ucm?
ThanksInformation fields are metadata fields that describe the content - by default they will appear on the interface and be searchable etc.
Application fields are a special sort of meta field normally used behind the scenes to help with the logic of forms/templates. Application fields do not normally appear on the interface and are not searchable.
More simply put if you just want to add content metadata just use Information Fields
Tim
Edited by: Tim Snell on 16-Sep-2010 06:51 -
On the back end, I have a field that stores
time ticks (time in seconds plus 1... We call
this column IDMTICK) When a user enters, data
into this field through a Form 6i application, I need to convert the entry into time ticks. So if the user enters 03:00, it must store ((3x60x60)+1). When a user views this record, I need the front to
show 03:00 (basically the reverse of the
calculation made). CAN you suggest how to
proceed with this type of problem.have a hidden date field with date format of hh24:mi:ss
and you can set it's value with seconds.
The database saves date fields with seconds.
All you need to do is synchronize this field and the one that you display. which should have a format of hh24:mi
Maybe you are looking for
-
G5 1.8 SP 900mhz FSB won't sleep after installing 10.4.6
I have one of the original PowerMac G5 1.8 SP w/900 mhz FSB (which Apple promptly discontinued). I recently updated my OS from 10.3.4 to 10.4.6 from a retail DVD. Since updating, my computer will not go into sleep mode from the apple icon. When selec
-
Equium M70: I need a name of the sound card
I have a toshiba m70 equium and i have now bought a creative notebook sound 5.1 soundcard. I need to know the current name of the sound currently on the laptop before I install the new one. CAN ANY ONE HELP ME? THANKS
-
Read lines from text-file in specified [ITEM]
Hello, are there any functions integrated in Labview to read a text-file which looks like this: [ITEM-NAME_01] parameter1 = here parameter2 = 1123 parameter3 = a453 [ITEM-NAME_02] parameter4 = here parameter5 = 1123 parameter6 = a453 Can this be done
-
Shared photo streams don't sync videos on mac.
I have a shared photo stream from a friend. Videos sync on my phone but not into my iphoto on my mac. Any ideas why?
-
Change in Work item Text for Approval Workflow WS14000133
Hi, I need to change the work item text for Shopping Cart Approval Workflow WS14000133. I have created an Attribute in Business Object BUS2121 and called the same attribute in work item text. In PFTC -> Redefine Work item text - > and i have defined