Add duration to date in google sheet formulae - date

I have a duration 120:00:00.000(120 is an hour and 00 is minute and 00 is sec) and date is 2/14/2020 13:40:00 in google sheet cells
I want to add duration and date (date + duration) using google sheet formulae
the result will be 2/19/2020 13:40:00

try:
=TEXT(VALUE(B2)+A2; "d/m/yyyy h:mm:ss")
or:
=TEXT(B2+A2, "d/m/yyyy h:mm:ss")
or just:
=B2+A2
and format it internally

Related

How to add 24 hours to a millisecondsSinceEpoch time in flutter?

I need to add 24 hr on the selected date slot in the calendar in milliseconds since the epoch.
As in the below code if I add 24 hr it will give me 00:00 time for the same day so I tried to use this (23, minutes: 59, seconds: 59) which is wrong.
Please suggest...
DateTime initialTime = selectedDate.value;
DateTime finalTime = selectedDate.value.add(new Duration(hours: 23,minutes: 59,seconds: 59));
int finalTimeInEpoch = finalTime.millisecondsSinceEpoch;
print('This is the initial time for selected day --> $initialTime and This is the final time for selected day --> $finalTime');
int initialTimeForApi = initialTime.millisecondsSinceEpoch;
int finalTimeForApi= finalTimeInEpoch;
print('This is the initial time for selected day --> ${initialTime.millisecondsSinceEpoch} and This is the final time for selected day --> $finalTimeInEpoch in millisecondsSinceEpoch');
Use Like This
DateTime finalTime = selectedDate.value.add(Duration(hours: 24));
if this don fix the issue your problem is selectedDate.value is not a valid format date time

Dynamic Default Day Parameter

Good day,
I would like to create parameters with the following conditions:
Start Date Range between 03/01/2019-03/31/2019 (done)
End day range 03/01/2019-03/31/2019
Default end day is set to the day of today but in March (so if I open the wbook tomorrow it will be 03/22/2019
It's a bit complexe and your help is much appreciated.
1- Create calc field that takes day of today and month/year
DATEPARSE("dd, MM, yyyy", str(Today()) + ", " + str(03) + str(2019))
2- In End date parameter > when opening workbook > select calculated date

hour() function of excel in postgres (equivalent)

I am working recently with postgres and I have to make several calculations. However I have not been able to imitate the HOUR () function of Excel, I read the official information but it did not help me much.
The function receives a decimal and obtains the hour, minutes and seconds of the same, example the decimal 0,99988426 returns 11:59:50. Try doing this in postgres (i use PostgreSQL 10.4) with the to_timestamp function: select to_char (to_timestamp (0.99988426), 'HH24: MI: SS'); this return 19:00:00. Surely I am omitting something, some idea of how to solve this?
24:00:00 or 86400 seconds = 1
Half day(12:00 noon) or 43200 seconds = 43200/86400 = 0.5
11:59:50 or 86390 seconds = 86390/86400 = 0.99988426
So to convert your decimal value to time, all you have to do is multiply it with 86400 which will give you seconds and convert it to your format in following ways:
SELECT TO_CHAR((0.99988426 * 86400) * '1 second'::interval, 'HH24:MI:SS');
SELECT (0.99988426 * 86400) * interval '1 sec';
There are two major differences to handle:
Excel does not consider the time zone. The serial date 0 starts at 0h00, but Postgres uses the time zone so it becomes 19h. You would need to use UTC in Postgres result to have the same as in Excel.
select to_char (to_timestamp (0), 'HH24: MI: SS'),to_char (to_timestamp (0) AT TIME ZONE 'UTC', 'HH24: MI: SS');
to_char | to_char
------------+------------
19: 00: 00 | 00: 00: 00
Excel considers that 1 is one day, while Postgres considers 1 as 1 second. To get the same behavior, multiply your number by the 86400, i.e. the number of seconds in a day
select to_char (to_timestamp (0.99988426*86400) AT TIME ZONE 'UTC', 'HH24: MI: SS');
to_char
------------
23: 59: 50
(1 row)

Microsoft Access DateDiff + Difference in time if end time is next day

I have a table with records, where each record has a date column, then a start time column and end time column.
I am trying to do a datediff to get the duration in hours from start to end date with DateDiff('s',[Start Date[,[End Date])/3600.
This works perfectly for End dates that are on same day as date column, but sometimes the end date would be the next day like 12:45 AM. The date diff will give me a large negative number, how do I let it know its next day?
I dont own the data, so not much I can do with the table
Thanks!
Try something like this:
DateDiff('s',[Start Date],DateAdd('d',IIF([End date]<[Start Date],1,0),[End Date]))/3600
It can be done with pure math:
TotalHours = TimeValue(CDate([End Date] - [Start Date] + 1)) * 24

Add current timezone difference to timeintervalsince1970 in swift

I have an API call that asks me to convert dates to timeIntervalSince1970 in ms and they also want me to add the correct time zone difference. So my code is at the moment:
if let timeStamp = incident?.publishedTimeStamp as Date? {
let roundedDown = Int(timeStamp.timeIntervalSince1970 * 1000)
publishedDate = String(roundedDown)
}
This gives me a number that if I insert it in here:
https://www.epochconverter.com/
I get this result:
Now as you can see, the GMT time (the top result) is what I at the moment achieve. I need to add enough ms so that the Your time zone section would be in the GMT section. I hope this makes sense.
So how can I get the number in ms that represents the difference between the current time zone from GMT so I can sum it with my current result?
var roundedDown = Double(TimeZone.current.secondsFromGMT(for: timeStamp)) + timeStamp.timeIntervalSince1970
roundedDown *= 1000
publishedDate = String(Int(roundedDown))