Hi All,
I am passing one parameter which is datekey into JSON. Using that datekey I want to check whether it falls in between startdatekey and enddate key.
How can I achieve that?
For instance-
I have below record in an entity
Startdatekey EndDateKey Target
20210112 20210114 34
So I pass datekey as 20210113 then it should the above row as the passed datekey falls in the above date range.
Please help
@OliverRodrigues
@OOlashyn
Hi, how is your datekey field represented in your Dataverse? is it a string?
If it is, you can't really compare using between/before/after. You are just comparing texts.
Can you convert that to a datetime field?
If you can't, I think the only way would be retrieving your data via Liquid and loop through the data, in your loop you need to convert via Liquid and then compare with the current date. Based on that you can ignore and go to the next record.
This might have performance impact as you would have to retrieve all the data before actually filtering, but I can't think of any other solution.
Power Apps Portals Super User
Hi,
I the datekey is a text field. If I use it as a date field then it is also not working. I used below condition-
Liquid error: Sequence contains no matching element
Hi, yes it won't work because the field is a string.
Does the field have to be a string? Is there any reason it is not a Date field?
Power Apps Portals Super User
I checked that field using the data type as date field but it is not working.
Hi @Anonymous,
So cr579_startdate, cr579_enddate, and cr579_date are all Text fields, and when you use just cr579_date the query is fine but as soon as you use start&end it breaks? Is the value for pdatekey the same as the ones for start&end? And does this happen for both valid & invalid inputs?
It seems the Liquid is throwing a .NET sequence error, so it doesn't like something about the results.
FYI, @OliverRodrigues: I tested this query after making content snippets as 1001 and 1005 and it works 😅
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="adx_contentsnippet">
<attribute name="adx_contentsnippetid" />
<attribute name="adx_name" />
<attribute name="createdon" />
<order attribute="adx_name" descending="false" />
<filter type="and">
<condition attribute="adx_name" operator="ge" value="1000" />
<condition attribute="adx_name" operator="le" value="1004" />
</filter>
</entity>
</fetch>
@justinburch OMG.. I am scared to know greater then/less then works with string. D365 is probably trying to parse as numeric or something. I might play around later via SDK.
Power Apps Portals Super User
Hi @justinburch and @OliverRodrigues,
All fields here are text field -
The below syntax is working perfectly fine and giving me desired result (if you observe I am passing two parameter i.e. pstartdatekey and penddatekey, and checking it into a single column i.e. cr579_startdatekey -
Hi, can you share your code where you assign the value into pdatekey variable?
Power Apps Portals Super User
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
User | Count |
---|---|
8 | |
3 | |
2 | |
1 | |
1 |