Get data every 3 months

Here the solution… sorry!

But is this the best way to do this?

Can you tell us how is this api works?Any what is your way exactly.you mean you will set the api to get data for a specific instant.Or you we will get data every 3 months? So we can help you better.Also have you tried your way?Does it work?

But does the API accept date as parameters for filtering historical dates? I did not understand.
From what you said, the API only returns the last 3 months, so I guess you can’t filter by date as this is done internally in the API.

Thank you!

Is this better than working with milliseconds?
Looking here, it is safer to do the calculation for milliseconds because I don’t have to worry about whether the day of the month exists or not, for example.

Here…

1 Like

Yes, but the interval has to be 3 months.
So I will make several requests to get a longer period.

nope.You can reread my post.I use another block which is make millis to convert this instant to mellis.

So there is no way.you can try to add them in a for loop so you can get them with the least amount of blocks :+1:And you can use makeMellis block to convert a normal instance ( you get from make instance from parts block ) to mellis.

1 Like

But friend, if the API doesn’t allow it, how will it do it?
Ok, Now , I saw API parameters. :+1:t2:

2 Likes

I’m working around an API limitation.
I will convert the current moment to milliseconds and then subtract 3 months from each request I make.
So I will take the history of the time I want back, making one request after another.

Now I don’t know exactly how I’m going to convert the date to LONG.
Any idea?

In app inventor ( and kodular as well ) a long isn’t different from an int ( in other languages they are.) So you can easily get data without converting any thing at all.:wink:

2 Likes

This should be simple, but I don’t remember how to do it.

Do you mean the way of getting the data 3 monthes by 3 monthes.I can make it with this way.
for each number from 90 to ( the number of days you want the counter to stop on for example 182 (that means that we will get the data of the last 6 months 3 by 3) by 90
you will now form your request.In the start days parameter set it to number - 90 and the end day to the number.that’s it! now get data from the api with this url you have.

You don’t know how to do what? Do the transformation in Long or use the API?

1 Like

Sorry for the confusion.
I was thinking of converting the dates in LONG to pass as a parameter …

But it must be simpler than I think …
The LONG of the parameter must be the number of days.

I will test and return here.

Thank you guys!

You can try this way as well:

1 Like

All the details of your question have been answered above. Now is the time for you to try.

1 Like

Thank you guys.

But I will have to do the math in milliseconds, because that’s how the api works.
I will use the Get Millis block of the Clock component for this and make an account to subtract 3 corresponding months in milliseconds.

1 Like

Well you can use this way:


But at the ending add this blocks:
get mellist from instant: make instant from parts : and set all the parameters to 0 except the days set it to the result you got from the above way.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.