Set Datetime to 00:00:00 in LogicApp - azure

currently I am working with a Logic App, I want to set the hours to a given DateTimeFormat to 00:00:00 with a Variable. After that I try to add an int variable as hours with it, but that doesn't work. Any ideas?
formatDateTime(addHours(utcNow(), -utcNow().Hour + variables('Daytime')), concat('yyyy-MM-ddTHH:mm:ss', variables('DateTimeOffset')))

It would be nice to know what values the variables have in them because without it, it's not as easy to provide a complete answer, but, bottom line, you can't use + like you have in the expression.
If you want to add and minus, etc., you need to use the inbuilt function add.
The expression builder is a function based approach.
Without knowing exactly what you want to achieve, something like this will help you along ...
concat(addHours(formatDateTime(utcNow(), 'yyyy-MM-dd'), 6, 'yyyy-MM-dd HH:mm:ss'), '+06:00')
... but will need to be cleaned up.
You also need to replace my hardcoded values with your variables.

Related

Python 3.10 datetime strptime not picking up time zone?

I have a timestamp embedded in some JSON data as a string, for ease of inspection and modification. An example looks like this:
"debug_time": 1670238819.9747384,
"last_saved": "2022-12-05 11:13:39.974725 UTC",
When loaded back in, I need to convert it back to a float for comparison against time.time() and similar things, however, I can't seem to find the magic incantations to have it restore the correct value.
In restoring the JSON data, I attempt to convert the string to a float via strptime() like this:
loaded_time = datetime.datetime.strptime(obj.last_saved, '%Y-%m-%d %H:%M:%S.%f %Z')
This does restore the timestamp to a valid datetime object, however calling .tzname() results in None, and my attempts to use loaded_time.replace(tzinfo=zoneinfo.ZoneInfo('UTC')) have not yielded any useful results.
In short, emitting loaded_time.timestamp() yields 1670267619.974725, which is 8 hours ahead of what it should be. I've tried using .astimezone(), in various permutations, but can't find a way to correctly have it convert to the client's local time.
I even tried to hard-code in my own time zone US/Pacific but it stubbornly refuses to give me that original debug_time value back.
This doesn't seem like it should be a difficult problem, but clearly I'm misunderstanding something about how python 3's time handling works. Any ideas are welcome!
Thank you for your time!
you have to use built in function replace like
.strftime("%Y-%m-%dT%H:%M:%S.%f%Z").replace("UTC", "")

How to use regex inside objectContaining

Essentially trying to test the result of a function that contains 3 irrelevant string properties (irrelevant to this question). But a 4th property that is a ISO 8601 string that gets created when the function gets executed. I have no way of knowing what this exact value will be, so I want to test the property via regex. Usually I'd do something like this (which would work but not as clean):
expect(desiredProperty).toMatch(ISOPattern); // ISOPattern = regex i made that works
But doing it this way would mean i need to write this expect for every single property, whereas something like this is more clean and easier to read:
expect(result).toEqual(
expect.objectContaining({
id: mockEmail,
otpPassword: mockOtpPassword,
expire: 1000 * 60 * 60,
expire_at: expect.toMatch(ISOPattern), // NOT WORKING, FAILS
})
);
So I am wondering, is doing something like the above possible at all? I could just not check that property in my expect.objectContaining function, and add another expect to do what i mentioned above. But again, wondering if I could have the best of both worlds.
Not sure if I formatted my post right but essentially this is what I ended up doing (i mentioned this in the OP):
expect(result).toEqual(
expect.objectContaining({
id: mockEmail,
otpPassword: mockOtpPassword,
expire: 1000 * 60 * 60
})
);
expect(result.expire_at).toMatch(ISOPattern);
So the idea here was to get rid of the extra expect call (if you notice here I am checking against the same object result, but I wont know the value of the date and its not important anyways so I just want to check some regex I wrote (whether this works or not is irrelevant although the regex works for sure), and somehow do the regex check inside the expect.objectContaining function, but I dont think I did a good job at formatting my question right so thats probably on me.
Open to anyones help if they see a way to do what im talking about.
The code in this solution is what I am using now, the question I am trying to ask is if theres a better way to do this. The regex working is not relevant, although I know 100% it does work. I did not provide this regex because its literally not what I am asking or relevant to the solution I am seeking.

How to concatenate two functions into one function?

I have a set of data that is generated:
=((E31/320)^2)/(2+(E31/380))
=((E32/320)^2)/(2+(E32/380))
=((E33/320)^2)/(2+(E33/380))
...
I want to create a sum of these, but I don't want to just SUM them together; I want to write a function that put these together. I came up with this row:
=SUMPRODUCT(((ROW(E1:INDEX(E31:E63;C34)))/320)^2/(2 + (E31:E63/380)))
The problem with this line is it seems to overdo the whole thing. I need to somehow use one variable for the both E31:E63 intervals, because it will otherwise loop through the second E31:E63 n-times, instead of using the same value.
As I see it, there are two solutions.
Write the data in columns, but using the first solution
Write the function, but try to find something that makes the two E31:E63 work as one variable.
I want to implement the second option.
I believe
=SUMPRODUCT(((E31:E63/320)^2)/(2+(E31:E63/380)))
Will do what you want.

Get BuiltInParameterId from BuiltIn Parameter ElementId in Revit

Is there a Way to get the BuiltInParameterId (Ex:BuiltInParameter.SHEET_SIZE)
from a Parameter ElementId.
I have a number extracted from an Schedule Field (-1010106)
and I want to get the BuildInParameter-id.
Currently I am doing it like this:
BIPdic = {i.value__ : i for i in BuiltInParameter.GetValues(BuiltInParameter)}
bipid= BIPdic[-1010106]
I could not find an easier way. (Its easy, but I have to built a dictionary
from all (over 3000 BuiltInParameters)).
THX
tillbaum
I am not absolutely sure I know what you mean. Check out the description of the ElementId constructor taking a BuiltInParameter input argument.
You can also take a look at the built-in parameter checker BipChecker and its BipChecker GitHub repo. It iterates over all built-in parameter values and tries to retrieve a parameter value for each one.
That sounds pretty similar to what you are after with your dictionary.

Cognos LIKE function problems

I am facing a problem on Cognos 10 with the LIKE function.
I have a varchar field named EOM_DATE which contains the end of months values, for example: 2017_01, 2017_02, etc.
I want to build a query like this:
[RiskDM2].[ADAV_RISKDATAMART].[EOM_DATE] LIKE ('2016%', '2017%', '2018%')
because I want that only the specified years to show.
Any solution?
I have tried different solutions using LIKE, STARTS WITH and even IN, but none of them seems to work.
You have to break it out. The pattern you are using only works with IN and IN doesn't support wildcards.
Try this:
[RiskDM2].[ADAV_RISKDATAMART].[EOM_DATE] LIKE '2016%'
OR
[RiskDM2].[ADAV_RISKDATAMART].[EOM_DATE] LIKE '2017%'
OR
[RiskDM2].[ADAV_RISKDATAMART].[EOM_DATE] LIKE '2018%'
This is effectively a long-form of IN, but it allows you to use the LIKE operator.

Resources