BigQuery Convert Int to Timestamp and Add to Another Timestamp - time

I'm not sure how to approach this issue. I used this statement below to convert an integer into a timestamp. The goal is to convert "duration_minutes from an integer to a timestamp, add the hours, minutes and seconds to the startTime.
TIMESTAMP_SECONDS(s.duration_minutes)
output:
1970-01-01 00:03:05 UTC
startTime
2016-07-13 00:00:00 UTC ```

Related

Parsing milliseconds from a unix date in Ruby

Converting a DateTime to unix convention using %s%L (%s means seconds since Jan 1st 1970, %L means to append 3 digits to represent milliseconds) give this:
DateTime.now.strftime '%s%L'
=> "1656279075654"
How can I get a DateTime back from this?
DateTime.strptime('1656279075654', '%s%L') gives an error, as strptime doesn't seem to know %L strangely.
secs = '1656279075654'.to_f / 1000
DateTime.strptime(secs.to_s, '%s')
or
DateTime.strptime('1656279075654', '%Q')
(%Q - number of milliseconds since 1970-01-01 00:00:00 UTC)

get milliseconds since 1970 from string

I got a string like this:
"2016-08-12 06:13:24 UTC"
How can I convert this date time string to milliseconds since January 1, 1970 UTC ?
Try
require 'date'
DateTime.parse("2016-08-12 06:13:24 UTC").strftime('%Q')

How to interpret RFC3339 UTC timestamp

How should I interpret all aspects of the following timestamps? Where is the time based and how do timezones apply?
2015-11-15T14:45:28Z
2015-11-15T14:45:28.9694Z
2015-11-15T14:45:28.969412345Z
Below is my thoughts...
Date: 2015-11-15
???: T
Hours: 14
Minutes: 45
Seconds: 28 OR 28.9694 OR 28.969412345
???: Z
Most of your values are attributed correctly. The date portion (2015-11-15) is in the order YYYY-MM-DD, time in HH:MM:SS.ffff.
T indicates the start of the time portion of the date time.
Z indicates the time zone is UTC. Next to Z, you could have a format like Z+02:00, which indicates the time zone is UTC + 2 hours.

Lua UTC time inconsistencies

Lua 5.1 doc says:
If format starts with '!', then the date is formatted in Coordinated
Universal Time.
If format is %c, !'s behavior seems correct
local date_1 = os.date("!%c")
local date_2 = os.date("%c")
print("utc date: "..date_1)
print("not utc date: "..date_2)
If format is *t, !'s behavior seems swapped
local time_1 = os.time(os.date("!*t"))
local time_2 = os.time(os.date("*t"))
print("should be utc time, but is not: "..time_1) -- this should be UTC, and is not
print("should not be utc time, but is: "..time_2) -- this should not be UTC, but is
Dates are tested with: http://www.epochconverter.com/
Why is that?
The table returned by os.date("!*t") and os.date("*t") is correct. I'm printing only the hour field. Note that they are consistent with %c format:
local date_1 = os.date("!%c")
local date_2 = os.date("%c")
print("utc date: "..date_1)
print("not utc date: "..date_2)
print("utc date hour: " .. os.date("!*t").hour)
print("not utc date hour: " .. os.date("*t").hour)
Output on my machine (China Standard Time, UTC+08:00):
utc date: 02/06/15 02:02:29
not utc date: 02/06/15 10:02:29
utc date hour: 2
not utc date hour: 10
However, os.time takes the table, assuming it's the local time, and returns the epoch. So, the local time is converted to the real epoch, but the utc time is not.
print(os.time{year=1970, month=1, day=1, hour=8})
outputs 0 on my machine.

format subtract dates result to "hh:mm:ss"

I need to format subtract 2 long date time result to "hh.mm.ss"
open date closed date subtracted
01/01/2012 16:04 04/01/2012 17:07 3.01:02:58
02/01/2012 08:52 02/01/2012 17:03 08:10:27
using
closeddate.subtract(opendate)
return result in format D.hh:mm:ss
and using
DateDiff("h", OpenDate, closeDate)
return hours only (no minutes or seconds)
Also tried
closeddate.subtract(opendate).tostring("hh:mm:ss")
not working
as many Microsoft forums answered there is no way to do that
so i used
DateDiff("s", OpenDate, closeDate)
and passed result to helper function return calculated time in format hh:mm:ss

Resources