|
| Performing direct calculations (IntegerToDate) |
| Iniciado por guest, 11,jul. 2017 22:14 - 5 respuestas |
| |
| | | |
|
| |
| Publicado el 11,julio 2017 - 22:14 |
i was wondering if theres a way to perform direct calculations on a integer somthing like this;
d1,d2,d3,d4 are dates d1=IntegerToDate(date source,"MM") +6 (+6 months) d1=01 d2=IntegerToDate(date source,"MM") +6 (+6 months) d2=11/01/2018
instead of returning 11/07/2017 it now returns 11/01/2018
cuz using LastDayOfMonth() then convert it back to integer is such a hustle ,... is the integer not designed to perform calculations on directly? I mean after all we talking about a rapid development platform.
Or am i just missing the right command?
Also i find the example calculating on dates some what disepointing (to low on example content) |
| |
| |
| | | |
|
| | |
| |
| Publicado el 11,julio 2017 - 22:40 |
Hi
if I understand correctly the question, you should do this:
dDate is date=DateSource DDate..Month+=6 info(dDate)
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 11,julio 2017 - 22:41 |
Hi,
Why not simply add the days since you use a date variable? It is way more easy, unless I'm missing something.
d is Date = "20170711" d..Day += 125 Trace(d) // 20171113 d..Month += 14 Trace(d) // 20190113 Best regards, Alexandre Leclerc |
| |
| |
| | | |
|
| | |
| |
| Publicado el 12,julio 2017 - 02:50 |
@alexandre
i tried to a edited version of ur code in a loop buth it doesent seem to work break fails.The code below d4 =the ad date , d2 the rule ,d5 date of edit1 was trying to find out last jump point
LOOP IF d4 = d5 THEN BREAK Trace(d4,N2)
d4..Month =+ d2 N2 ++ END
So let me explain a litle bit of what i am trying to do.A date gets addit with a (jump rule) (x amount of months)only moving forward.Edit1 and Edit 2 form a selected perioode (add date and selection can be in difrent year)(variable)can be one month can be sevral.I need to find out if 1 or more jump starts in the selected perioode and if so what date.I expected somthing simular like this to be in the example as i said early the example is somewhat lacking and not realy practical in my vieuw.(i cant use Hfilter or use organiser chart in this case) |
| |
| |
| | | |
|
| | |
| |
| Publicado el 12,julio 2017 - 10:57 |
d4 msut be one date varialbe and d2 numeric (int, currency,...)
just use d4..Month += d2 instead of d4..Month =+ d2 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 12,julio 2017 - 14:57 |
Hi testal,
I do not know if the documentation is not clear enough or if your approach to the problem is the good one. Your problem is not a very difficult one to solve (given the parameters you shared). For the documentation, see http://doc.windev.com/en-US/… and also all the variable types (at the end of the same documentation page in the "See also" section).
If you are simply increasing the month part with a fixed number of months, then you can check the dates with a modulo.
For each DateToCheck between RangeStart and RangeEnd IF modulo(DateToCheck..Month, FixedMonthIncrement) - StartingDate..Month = 0 THEN // You got one END End
The StartingDate is your "add date". This example is not sensitive to the day, but to the month. This will work withing the same year. (It is a simple example.)
If you have to check on multiple years, you can use a duration variable and do the same. This code will be sensitive to the exact day (it has to make a real complete month):
For each DateToCheck between RangeStart and RangeEnd duration = DateToCheck - StartingDate // This gives the exact difference between your starting point and the date to check. Adapt if you need sensitivity only on the Month level and not on the exact day level. (Tip: Put the day at 1 : DateToCheck..Day=1, StartingDate..Day=1). IF modulo(RoundDown(duration..AsMonths), FixedMonthIncrement) = 0 THEN // You got one END End
The advantage is that you only compute the specific dates you need to check instead of looping over a potentially long period. (This is only pseudo-code, not tested, but the modulo approach will definitely work if your date increment is fix, ie. not variable.)
Best regards, Alexandre Leclerc |
| |
| |
| | | |
|
| | | | |
| | |
|