Setting dates relative to other dates

prototype user shared this question 23 months ago
Answered

I need to be able to dynamically set dates. For example, one day prior to the system date or one day after the date displayed in another date widget. It is too cumbersome to try to parse out the slashes and manually replace the date especially since each month has a different number of days.

Comments (8)

photo
1

Dear Rechell,


I've just realised that by oversight we didn't reply this post. Can you elaborate more on what you mean? Are you using the date widget?


Best,


Sonia Durán

photo
1

I mean doing "date arithmetic". For example set the value of a date box to one day after today's date.

photo
2

Hi Rechell,

I know you would prefer the ability to do date arithmetic to be built into JIM, but in the event that it is not and it is critical that you are able to do it, you can accomplish it using the expressions I've built in the attached prototype (see screenshots below). Download the file and change the extension from .rar to .vp. It is not compressed.

I'll warn you, the expressions to achieve what you are hoping to do are pretty elaborate, but I believe them to be accurate. They are based upon formulas using Julian Day Count integers, described here:

https://quasar.as.utexas.edu/BillInfo/JulianDatesG.html

Should you decide to dig into it, I've tried to mimic the formulas (variables, etc.) as they appear on the linked site to make them easier to follow/decipher.

Note to Justinmind developers: If these formulas were converted into functions (eg. JDC() for Julian Day Count and GCD() for Gregorian Calendar Date), date arithmetic would be possible. Also, as you can see by the expressions, it would be huge step forward in simplifying them if a truncate function was available. The work around makes the expressions a great deal larger.

Cheers!!

030bda53b43810a39513ae3de531c2b2 fe1d7cc5fbb9d9247f4f2140b1d96daa

45d014a4d5852f78a52e849e5fcccb18 . e5553b0fa9ed837614321ebde1fdd4b6

P. S. The file I originally attached was the wrong one. I noticed it shortly after (20 minutes or so) and replaced it with the correct file. As long as you have the file "date_calculations_prototype.rar", you have the correct one. ("date_difference_calculation_prototype.rar" is the incorrect one)

photo
1

Hi there,


Thank you so much for your contribution @eggroll! :) I hope this helps @RechellSchwartz.


Best,


Sonia Durán

photo
2

Thank you, @egroll. What you did is very impressive. However, I do feel date arithmetic is standard functionality that should be incorporated into Justinmind. Any chance of seeing this in a future release?

photo
1

Unfortunately no plans at the moment.


Best,

photo
1

Any chance of getting a truncate function any time soon?

photo
1

You could do that with the Round function "trunc(x)=round(x-0.5,0)" however, would only work with positive numbers. Anyway, I will transfer your suggestion to our development team.

Best,

photo