I was fixing some legacy code and found an strange behavior.
DateTime.TimeValue method for 12:00:00 AM, some time returns 0 and some time 12:00 AM.
Related
I am looking to create a microsoft flow to check if an email was received between 18:00 and 18:15 Pacific Time. Ideally this would be a single formula instead of comparing time >= 18:00 and time <= 18:15
Currently I have:
convertTimeZone(triggerOutputs()?['body/receivedDateTime'], 'UTC', 'Pacific Standard Time', 'HH:mm')
to convert the datetime from UTC to PST in HH:mm format. My next thought was to subtract a time (18:00) from this and get the difference in minutes, then checking that this value is between 0 and 15
I've broken out my answer but you can do what you need with it. Personally, I think this is the most transparent and easiest approach but it's up to you.
Flow
To break it down ...
Firstly, the first step is me merely initialising a string that can be used to get the time from.
Next, I transform the minutes into an integer using the following expression (change out the locale as needed) ...
int(formatDateTime(parseDateTime(variables('Received DateTime'), 'en-AU', 'yyyy-MM-dd HH:mm'), 'HHmm'))
Finally, I do the comparison using this expression ...
and(greaterOrEquals(variables('Time Integer'), 1800), lessOrEquals(variables('Time Integer'), 1815))
Invalid
Valid
I am at a loss, i looked around the internet and stackoverflow but every so called solution is giving either errors or plainly don't work.
I have the following setup.
4 fields (setup in date dd-mm-yyyy, hour hh:mm:ss) seconds are not important.
start date : 7-1-2020
start hour : 23:30:00
end date : 8-1-2020
end hour : 03:50:00
What i want to happen is to calculate the diffrence in 'hours, minutes' between the end and the start date, hour. But when I calculate and change the end date to lets say 09-01-2020 it does not count the extra 24h at all.
Use Text format:
=text(A3-A1+A4-A2,"[H]:MM")
You need to format the time difference as a duration using the custom format
[h]:mm
for hours and minutes
or
[h]
for whole hours.
There are some good notes on how it works in Excel here and as far as I can tell from testing it Google Sheets is the same.
Alternatively, if I read your question as wanting to drop the minutes and seconds from the times before doing the calculation, you could use
=(B3-B1)*24+hour(B4)-hour(B2)
and just format the result as a normal number.
After alot of fiddeling and this post i came to the conclusion that the main issue was not laying within the mathematical but within the format of the cell.
By default all time values in sheets are 24h max.
So the basic formula =start - end
The time format needed should be
more date time format
elapsed hours : elapsed minutes
apply
Now you should see the correct elapsed hours and minutes
I am laying bets through the Betfair API and noticed something very strange. For some events the time is off on both market and event results.
My account date and time are set to Europe/London. Not that it matters, the API outputs whatever zone it wants anyway, apparently at random (sometimes GMT other times London or whatever other timezone, but the ISO timestamp does not include +0100 or whatever GMT offset), all this despite the fact that my account is set to EU/London.
For example let's take this event Superettan / Jonkopings Sodra v Varnamo
The API output is:
{"event"=>{"id"=>"28836884",
"name"=>"Jonkopings Sodra v Varnamo", "countryCode"=>"SE",
"timezone"=>"GMT", "openDate"=>"2018-08-13T18:00:00.000Z"
}, "marketCount"=>2}
Their website however says the event starts at 17:00 GMT / 18:00 London (now GMT+1).
There are hundreds examples like this. Cannot get anything out of Betfair support, they take days/weeks to reply and when they do they just send some canned message.
Has someone seen this issue before? Or perhaps I am missing something?
Later edit: I had to dump all their market data to reach this conclusion: it appears that when their API says the timezone is GMT the event is actually on London, so GMT+1 right now, and for every other timezone (Eu/London, Perth, US...) the time is actually on GMT. Not sure what's up with that. Still investigating.
All times returned by Betfair are in UTC - that's just the way the API works. They also supply time zones which may or may not be correct. Use the time zones as an indication of the local time of the event. However, the time zones are very "hit and miss", so don't rely on them to be correct. In fact, over time you will notice lots of "data errors" for non-pricing info on Betfair markets. This is just the way it goes. so don't expect them to fix the errors
Event.openDate is documented as "The scheduled start date and time of the event. This is Europe/London (GMT) by default" while Event.timezone is defined as "[the] timezone in which the event is taking place."
So, in one sense, the openDate in your API output is correct because it says 18:00. However, it's incorrect because it includes the Zulu 'Z' suffix indicating GMT / UTC. The inclusion of 'GMT' in the timezone field: a) is wrong; and b) just serves to confuse matters, IMHO.
Instead, I've started to use MarketCatalogue.marketStartTime which is defined as "The time this market starts at..." which isn't quite the same as openDate but, if they're going to be different, usually on Betfair you're more interested in when the market goes in-play than when the actual match / race / game begins.
The Events I'm using to validate this approach seem to work better this way. Bearing in mind that the UK moves from BST on 27 October to GMT on 28 October, from the API I'm receiving these as MarketCatalogue.marketStartTime:
Liverpool v Cardiff: "2018-10-27T14:00:00.000Z" [Correct: 14:00 GMT is 15:00 BST]
F1 Mexico Grand Prix [qualifying]: "2018-10-27T18:00:00.000Z" [Correct: 18:00 BST is 19:00 GMT]
Burnley v Chelsea: "2018-10-28T13:30:00.000Z" [Correct: 13:30 GMT is 13:30 GMT]
My boss has asked me to write a function that can determine how much time each employee takes to complete their work in terms of hours spent per assignment. I have created two variables, one for the time work has begun and the other for the time it is completed. The beginning time stamp is to take the exact time the work is started. However, the ending time stamp is to take the day it is completed but I need to add a specific time of day.
For example, I start an assignment on 4/23/2017 4:07:00 PM. I finish the assignment on 4/24/2017. Assignments do not get checked off as completed until about 5:00 PM each day so he wants the time stamp on the finishing time to always be exactly 5:00 PM regardless of the specific time it was marked complete; only the date is of interest here.
I've successfully been able to get the exact timestamps to save but I am having inconsistencies getting my set time to stick to the determined date.
I used:
orderCompleteTimeStamp = CDate(orderCompleteDate + TimeValue("17:00"))
And it seemed to display correctly, however the actual value stored in orderCompleteTimeStamp when used in calculating the time difference is ONLY 5:00, so when it is trying to do 4/23/2017 1:55:26 PM - 4/23/2017 5:00:00 PM, the time difference shows -1028348.9. If I set orderCompleteTimeStamp back to just taking the exact time the calculation works correctly so I can only assume it is something with addition of the specific time.
Any ideas how I can get this to work?
The question isn't very clear, this code works fine for me;
Dim orderStartTimeStamp: orderStartTimeStamp = CDate("23/4/2017 13:55:26")
Dim orderCompleteDate: orderCompleteDate = CDate("23/4/2017")
orderCompleteTimeStamp = CDate(orderCompleteDate + TimeValue("17:00"))
WScript.Echo orderCompleteTimeStamp
WScript.Echo DateDiff("h", orderStartTimeStamp, orderCompleteTimeStamp)
Output:
23/04/2017 17:00:00
4
Assumed you are checking the difference in hours as the question doesn't specify.
If the problem is a date that already has a time component just use DateSerial() to pull out the date components and create a new date variable.
Dim dateFromDB: dateFromDB = "23/4/2017 18:23:02"
Dim orderStartTimeStamp: orderStartTimeStamp = CDate("23/4/2017 13:55:26")
Dim orderCompleteDate: orderCompleteDate = DateSerial(Year(dateFromDB), Month(dateFromDB), Day(dateFromDB))
orderCompleteTimeStamp = CDate(orderCompleteDate + TimeValue("17:00"))
WScript.Echo orderCompleteTimeStamp
WScript.Echo DateDiff("h", orderStartTimeStamp, orderCompleteTimeStamp)
Output:
23/04/2017 17:00:00
4
I am trying to get the Timezone of the device (windows phone). I used this class and the property BaseUtcOffset. I live In Jordan, and it was suppose to give me +3 hours, but instead it gave me +2. i think its the daylight saving time, but i have no idea how to use it, any ideas?
var x = TimeZoneInfo.Local.BaseUtcOffset; // x.Hours = 2
the correct timezone from timeanddate.com
You should use GetUtcOffset().
The BaseUtcOffset property returns the difference between UTC and the time zone's standard time; the GetUtcOffset method returns the difference between UTC and the time zone's time at a particular point in time.
That's the right response. The timezone is 2 hours ahead of UTC. Local time is 3 hours ahead of UTC.
You might want to look at GetUtcOffset() or IsDaylightSavingsTime().