Duration in time is giving in OSB xquery 3 hour but i need Duration 03 hour
By : יפה אגת
Date : March 29 2020, 07:55 AM
wish of those help Based on your example, I am guessing that you are using OSB 11 or some earlier version. You could try using fn-bea:format-number. Also, I would avoid using anything under op:* directly. code :
let $dt1 := xs:dateTime('2015-07-31T10:25:00')
let $dt2 := xs:dateTime('2015-07-31T07:15:00')
let $t1 := xs:time($dt1)
let $t2 := xs:time($dt2)
let $diff := $t1 - $t2
let $hour := hours-from-duration($diff)
return
<FlightDuration>{fn-bea:format-number($hour, "00")}</FlightDuration>
<FlightDuration>03</FlightDuration>
|
Convert start time and total duration to elapsed time per hour
By : mike faber
Date : March 29 2020, 07:55 AM
I wish this help you I have data on start time ('startTime', a date-time variable, POSIXct) and duration in minutes ('duration_minutes'): , Try this: code :
library(data.table)
library(lubridate)
library(magrittr)
df <-
setDT(df)[, start_ceiling := ceiling_date(startTime, "hour", change_on_boundary = TRUE)] %>%
.[, `:=` (
reps = ifelse(
startTime + (duration_minutes * 60) <= start_ceiling, 1, pmax(2, floor(duration_minutes / 60) + 1)
),
initial_diff = as.numeric(difftime(start_ceiling[1], startTime[1], units = "mins"))
), by = id] %>%
.[, df[df[, rep(.I, reps)]]] %>%
.[, startTime := pmax(startTime, floor_date(startTime, "hour") + hours(0:(.N - 1))), by = id] %>%
.[reps > 1, duration_minutes := c(initial_diff[.N],
rep(60, reps[.N] - 2),
(duration_minutes[.N] - initial_diff[.N]) %% 60), by = id] %>%
.[!(duration_minutes == 0 & reps > 1), ] %>%
.[, c("reps", "start_ceiling", "initial_diff") := NULL]
id startTime duration_minutes
1: 1 2018-01-01 12:15:31 44.48333
2: 1 2018-01-01 13:00:00 60.00000
3: 1 2018-01-01 14:00:00 60.00000
4: 1 2018-01-01 15:00:00 60.00000
5: 1 2018-01-01 16:00:00 60.00000
6: 1 2018-01-01 17:00:00 30.51667
7: 2 2018-01-02 23:43:00 17.00000
8: 2 2018-01-03 00:00:00 60.00000
9: 2 2018-01-03 01:00:00 43.00000
10: 3 2018-01-03 11:00:11 45.00000
11: 4 2018-01-04 10:00:00 60.00000
12: 4 2018-01-04 11:00:00 5.00000
13: 5 2018-01-05 00:00:00 60.00000
14: 6 2018-01-06 11:35:00 25.00000
15: 6 2018-01-06 12:00:00 10.00000
16: 7 2018-01-07 00:00:00 60.00000
17: 7 2018-01-07 01:00:00 60.00000
df <- data.frame(
id = c(1, 2, 3, 4, 5, 6, 7),
startTime = as.POSIXct(
c(
"2018-01-01 12:15:31",
"2018-01-02 23:43:00",
"2018-01-03 11:00:11",
"2018-01-04 10:00:00",
"2018-01-05 00:00:00",
"2018-01-06 11:35:00",
"2018-01-07 00:00:00"
)
),
duration_minutes = c(315, 120, 45, 65, 60, 35, 120)
)
df
id startTime duration_minutes
1 1 2018-01-01 12:15:31 315
2 2 2018-01-02 23:43:00 120
3 3 2018-01-03 11:00:11 45
4 4 2018-01-04 10:00:00 65
5 5 2018-01-05 00:00:00 60
6 6 2018-01-06 11:35:00 35
7 7 2018-01-07 00:00:00 120
|
Formula of Google Sheet to compute the rest of 24 hour duration from a timestamp?
By : user3454783
Date : March 29 2020, 07:55 AM
|
Redshift: splitting a time duration row by 24 hour period
By : Brave
Date : March 29 2020, 07:55 AM
may help you . Redshift has one painful "feature". It is a pain to generate a derived table. Let me assume that you have a table big enough to generate a tally or numbers table. Then, the rest is date arithmetic . . . but a bit complicated. I don't have Redshift on hand -- and it has a weird combination of date syntax from SQL Server and Postgres code :
with numbers as (
select row_number() over () - 1 as n
from t
)
select t.id,
greatest(date_trunc('day', t.fromdate) + n.n * interval '1 day', t.fromdate) as fromdate,
least(date_trunc('day', t.fromdate) + (n.n + 1) * interval '1 day', t.todate) as todate
datediff(hour,
greatest(date_trunc('day', t.fromdate) + n.n * interval '1 day', t.fromdate),
least(date_trunc('day', t.fromdate) + (n.n + 1) * interval '1 day', todate)
) as hours
from t join
numbers n
on todate > date_trunc('day', t.fromdate) + n.n * interval '1 day';
|
How to get time difference/duration in hour and minute along with in java?
By : Dhaaa
Date : March 29 2020, 07:55 AM
Does that help First of all, the duration should not be a Date, it should be a java.time.Duration. If you only want to the hour part and the minute part, you can do it like this: code :
Duration duration = Duration.between(goTOvisitTime.toInstant(), returnTime.toInstant());
int hours = duration.toHoursPart();
int minutes = duration.toMinutesPart();
String formattedDuration = String.format("%02d:%02d", hours, minutes);
|