Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi friends,
I just need to find the difference between two timestamp columns by minutes and also i have to remove seconds . Any suggestion would be really helpful.
eg: jan 12,2017 11:27:28 PM and jan 12,2017 11:37:22 PM
Actual answer using interval function including seconds: 9 minutes
Expected answer : 10 minutes (remove seconds and have to find difference)
I know it looks rather ugly, but AFAIK you can only consistently produce this outcome by doing exactly what you tell us to do: manupulate the seconds in the TimeStamp strings.
Create a Straight table with dimensions ORIG_RESTORE_TS and NEW_RESTORE_TS and the following expressions:
Strcat(ORIG): =Date#(Left(ORIG_RESTORE_TS, Index(ORIG_RESTORE_TS, ':', 2)) & '00' & Right(ORIG_RESTORE_TS, 3), 'MMM DD, YYYY hh:mm:ss TT')
Strcat(NEW): =IF (Len(NEW_RESTORE_TS) > 0, Date#(Left(NEW_RESTORE_TS, Index(NEW_RESTORE_TS, ':', 2)) & '00' & Right(NEW_RESTORE_TS, 3), 'MMM DD, YYYY hh:mm:ss TT'))
Diff: =Round(([Strcat(ORIG)] - [Strcat(NEW)])*24.0*60.0)
produces this:
No it doesn't look rather ugly, it looks extremely ugly. But it seems to work.
Hey Rob - The reason I thought it would need Floor was because the OP wanted to convert 01:55 sec to 01 min , 02:25 sec to 02 min. Ceil will convert it to 02 and 03, respectively, right?
Indeed, and at the other end: Floor(-01:55) = -2 and Floor(02:25) = -3 too.
And you can't switch between Floor() and Ceil() in your expression, depending on whether TimeStamp2 (or ORIG_RESTORE_TS) Is GE or LT than TimeStamp1, because that breaks other rows. Tough one...
May be try like
Interval(
(TimeStamp(Timestamp#(ts1,'MMM DD,YYYY hh:mm:ss TT'),'MMM DD,YYYY hh:mm')
-
TimeStamp(Timestamp#(ts2,'MMM DD,YYYY hh:mm:ss TT'),'MMM DD,YYYY hh:mm'))
,
'mm')
That is why I wasn't flooring the subtraction (well initially I did), but flooring the individual time stamps and then perform the subtraction
hi peter,
I tried the method which you have done. but i didnt get any value in diff column(restore variation in my table) as see in the attachment below,
Can you share your qvw file here or data in an Excel file?
It looks like both the Strcat columns contain strings instead of duals. The expression in the Diff column tries to perform calculations on numerical values and those calculations won't work with strings. What expressions did you use in the Strcat columns?
I have used the expression you gave. find below,
Strcat(ORIG):=Date#(Left(ORIG_RESTORE_TS, Index(ORIG_RESTORE_TS, ':', 2)) & '00' & Right(ORIG_RESTORE_TS, 3), 'MMM DD, YYYY hh:mm:ss TT')
sunny,
Please find the QVW and sample source file