Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 10 Monaten, 2 Wochen
Letzter Beitrag:
vor 10 Monaten, 2 Wochen
Beteiligte Autoren:
Alexandre Leclerc, Paulo Oliveira, testal, testa1, Fabrice Harari

Performing direct calculations (IntegerToDate)

Startbeitrag von testa1 am 11.07.2017 20: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)
d2=IntegerToDate(date source,"MM") +6 (+6 months)

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)



if I understand correctly the question, you should do this:

dDate is date=DateSource

Best regards

von Fabrice Harari - am 11.07.2017 20:40

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

von Alexandre Leclerc - am 11.07.2017 20:41


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


d4..Month =+ d2
N2 ++

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)

von testal - am 12.07.2017 00:50
d4 msut be one date variable and d2 numeric (int, currency,...)

just use d4..Month += d2 instead of d4..Month =+ d2

von Paulo Oliveira - am 12.07.2017 08: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/?1514040 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

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

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

von Alexandre Leclerc - am 12.07.2017 12:57
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.