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
Related
I am wondering about power automate flow and I issues I had.
I am trying to set up initialize variables for checking time (european standard time) in my rules.
Expression looks like this -
startOfHour(convertFromUtc(triggerOutputs()?['body/receivedDateTime'],'Central European Standard Time','t'), 't')
Under variables I have condition which (True/Not) like this -
YES - time is greater than 22:30 PM
NO - time is less than 8:00 AM
If condition is true, my e-mail is forwarded to another outlook mailbox.
If not, nothing happened.
But this flow doesn't work :D
Can you help me resolve it ?
Thanks a lot !
First part prtscrn
Second part prtscrn
Given the information provided, I suggest the following:
Get the current time.
Convert it to the desired time zone. You can use the built in function to avoid calculation errors.
Convert only hour and minute to Integer. For example, 14:33 would be 1433.
Compare integers. This is: if time is greater than 2230 and less than 830, then forward email.
The flow might look like this:
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 want to fetch record from the sys_user table which is updated at or after certain time stamp.
for that I have created rest request as
https:/service-now.com/api/now/v1//table/sys_user?sysparm_query=sys_updated_on>=javascript:gs.dateGenerate('2017-10-30','01:25:00')
I had converted current time which is in IST format into GMT and pass it to dateGenerate() function.
Problem statement -
I don't want to convert the IST to GMT, is there any way by which i can identify ServiceNow instance time zone at runtime and convert given time into that time stamp and get the users.
If i can pass this date and time in UTC format.
Ahoy!
This is a great question, and something that's quite difficult in ServiceNow (dealing with time-zones).
As such, I've written a tool to manage this for you. It's totally free!
The tool is called TimeZoneUtil, and can be found here:
https://snprotips.com/blog/2017/9/12/handling-timezones-in-servicenow-timezoneutil
You simply need to initialize a GlideDateTime object, set its' time-zone to IST, use setDisplayValue() to set its' time based on IST current time, then use .getValue() to get that same time in system time.
This is because getDisplayValue()/setDisplayValue() work based on time-zone, whereas setValue()/getValue() always return the corresponding system time.
EDIT: In order to make this a little more clear, I'll provide some example usage below.
var tz = new TimeZoneUtils(); //initialize with current time
gs.print(tz.getOffsetHours()); //prints out "-7" in my instance, as the system time is in Pacific.
tz.setTimeZone('Asia/Kolkata'); //sets the time-zone to IST/UTC+5.5
gs.print(tz.getOffsetHours()); //prints "5.5".
gs.print(tz.getGDT().getDisplayValue()); //Prints the current time in IST (2017-11-01 20:52:31 at the moment).
gs.print(tz.getGDT().getValue()); //Prints the current time in system time (2017-11-01 15:23:12 at present).
gs.print(new TimeZoneUtils().setTimeZone('Asia/Kolkata').getDisplayValue()); //Single line, also prints current time in IST: 2017-11-01 20:52:31
The first 6 lines there, demonstrate basic usage and explain how it works.
The eighth line however, demonstrates usage on a single line, which you can use inside a query string. For example:
sysparm_query=sys_updated_on>=javascript:new TimeZoneUtils().setTimeZone('Asia/Kolkata').getDisplayValue()
Hope this helps!
Tim Woodruff
Author, Learning ServiceNow & Building Powerful Workflows
Owner/Founder, SN Pro Tips
I have field in my table as "start_time" as string. E.g Value is "2014-02-07T02:00:00Z". This is provided by API.
We want to show this time as per the client time zone (May EST, Central, IST, Pacific time). For testing In my system I set time zone as (Estern Time (US&Canada))
I tried
start_at = "2014-02-07T02:00:00Z"
start_time = Time.parse(start_at.chop!)
gm_start_time = Time.gm(start_time.strftime('%Y'), start_time.strftime('%b'), start_time.strftime('%d').to_i, start_time.strftime('%H'), start_time.strftime('%M'), start_time.strftime('%S'))
event_start_time = gm_start_time.localtime.strftime('%m/%d/%Y %H:%M')
Result as:
2014-02-07 02:00:00 -0500 ==> start_time
2014-02-06 21:00:00 -0500 ==> gm_start_time
"02/06/2014 21:00" ==> event_start_time
Here I am trying is
convert the string to Time object
Converting that time to GMT
From GMT trying to find equivalent "loca ltime"
If central time is 2014-02-07T02:00:00Z, then local time should 2014-02-07T03:00:00Z
Why I am getting Feb 6th 21 hours. This is -5 hours from expected result. My timezone also -5 hours.
(Time is 24 hours format)
Anyone have any idea on what I am doing wrong?
I think you have some issues with understanding how to handle the time zones. The Z letter at the end of the timestamp indicates that the time is UTC, so apparently your API provides you the time in UTC. When you remove it by using chop! (note that you could simply use chop anyway), Ruby cannot tell anymore what the time zone is, so it's going to use your local time zone by default (I live in UTC+08:00):
1.9.3-p484 :006 > Time.parse("2014-02-07T02:00:00Z")
=> 2014-02-07 02:00:00 UTC
1.9.3-p484 :007 > Time.parse("2014-02-07T02:00:00")
=> 2014-02-07 02:00:00 +0800
Using Time.gm then becomes unnecessary since you already have the time in UTC (assuming the API always sends you timestamps in UTC).
Also, what you are exactly trying to achieve is a bit confusing because you have at least one typo in your post (unless you're trying to obtain a local time in Europe).
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().