Initialize Variables in Power Automate Flow - outlook

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:

Related

Microsoft Flow for datetime between 2 times

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

How do I create a strategy trigger for a daily trade at a certain time?

I want to test a simple strategy based on time: every day at fixed time check some conditions and go long. every day at fixed time exit.
Whatever I try to get timeOpenCondition I get syntax error.
Tried things similar to:
EntryTime = if hour=0800 and minute=0
ExitTime = if hour=1400 and minute=0
It feels like I don't get the concept of how this works. Appreciate any help!

Find the difference between 2 dates and check if smaller than a given value

my issue is that I want to be able to get two time stamps and compare if the second (later taken) one is less than 59 minutes away from the first one.
Following this thread Compare two dates with JavaScript
the date object may do the job.
but first thing i am not happy with is that it takes the time from my system.
is it possible to get the time from some public server or something?
cause there always is a chance that the system clock gets manipulated within the time stamps, so that would be too unreliable.
some outside source would be great.
then i am not too sure how to get the difference between 2 times (using 2 date objects).
many issue that may pop up:
time being something like 3:59 and 6:12
so just comparing minutes would give the wrong idea.
so we consider hours too.
biut there the issue with the modulo 24.
day 3 23:59 and day 4 0:33 wouldnt be viewed proper either.
so including days too.
then the modulo 30 thing, even though that on top changes month for month.
so month and year to be included as well.
so we would need the whole date, everything from current year to second (because second would be nice too, for precision)
and comparing them would require tons of if clauses for year, month, etc.
do the date objects have some predfeined date comparision function that actually keeps all these things in mind (havent even mentioned leap years yet, have I)?
time would be very important cause exactly at the 59 minutes mark (+-max 5 seconds wouldnt matter but getting rmeitely close to 60 is forbidden)
a certain function would have to be used that without fail closes a website.
script opens website at mark 0 min, does some stuff rinse and repeat style and closes page at 59 min mark.
checking the time like every few seconds would be smart.
Any good ideas how to implement such a time comparision that doesnt take too more computer power yet is efficient as in new month starting and stuff doesnt mess it up?
You can compare the two Date times, but when creating a date time there is a parameter of DateTime(value) which you can use.
You can use this API to get the current UTC time which returns a example JSON array like this:
{
"$id":"1",
"currentDateTime":"2019-11-09T21:12Z",
"utcOffset":"00:00:00",
"isDayLightSavingsTime":false,
"dayOfTheWeek":"Saturday",
"timeZoneName":"UTC",
"currentFileTime":132178075626292927,
"ordinalDate":"2019-313",
"serviceResponse":null
}
So you can use either the currentFileTime or the currentDateTime return from that API to construct your date object.
Example:
const date1 = new Date('2019-11-09T21:12Z') // time when I started writing this answer
const date2 = new Date('2019-11-09T21:16Z') // time when I finished writing this answer
const diff = new Date(date2-date1)
console.log(diff.toTimeString()) // time it took me to write this
Please keep in mind that due to network speeds, the time API will be a little bit off (by a few milliseconds)

How to get latest updated record from sys_user table which is modified at or after certain time stamp in ServiceNow

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

Fetch current time in 24 hours format in JMeter

How can I get current time in 24 hours format in JMeter.
I tried ${__time(hh:mm a,)} but it results in AM/PM format.
As per How to Use JMeter Functions guide JMeter's __time() function output can be controlled via SimpleDateFormat class patterns.
Looking into JavaDoc:
you don't need a letter
you need to use capital H for 0-24 hours or lowercase k for 1-23 hours
So change function to ${__time(HH:mm,)} and that should be it
In Apache JMeter 5.2, current time can be captured in User defined variable and then used in Rest payloads as following screenshot:
expression - ${__timeShift(yyyy-MM-dd'T'HH:mm:ss'.000+05:30',,PT0S,,)}
output - "2020-06-06T18:10:59.000+05:30"
Here, date and time format can be changed as per the need.
Once current date and time is captured in user defined variable then it can be used as "${now-date-time}" in REST requests.
It could also be possible that we face a scenario where there should be gap of, let's say, 1second between start time and end time while constructing request. In such case, following expressions can help:
now-date-time : ${__timeShift(yyyy-MM-dd'T'HH:mm:ss'.000+05:30',,PT0S,,)}
now-date-time-plus-one-second : ${__timeShift(yyyy-MM-dd'T'HH:mm:ss'.000+05:30',,PT1S,,)}
Following example better explains it:

Resources