Donnerstag, 31. August 2017

date calendar functions / adding number of month to a date

use java.util.Calendar
declare Calendar endCal!

xyear=2017
xmonth=8
xday=31

endCal! = Calendar.getInstance()
endCal!.set(xyear,xmonth-1,xday)
?str(endCal!.getTime())

endCal!.add(Calendar.MONTH,2)
?str(endCal!.getTime())

?endCal!.get(Calendar.YEAR)
?endCal!.get(Calendar.MONTH) + 1
?endCal!.get(Calendar.DATE)

---------------------------------------------------

declare Calendar endCal!
DATE_STA=-1
DATE_END=-1
num_of_month_to_add = 6
tmp$="2017-08-30T20:02:46.000+02:00"
if len(tmp$)>9 then
if tmp$(5,1)="-" and tmp$(8,1)="-" then
DATE_STA=jul(tmp$(1,10),"%Yl-%Mz-%Dz",err=*endif)
endCal! = Calendar.getInstance()
endCal!.set( num(date(DATE_STA:"%Yl")) , num(date(DATE_STA:"%Mz")) -1 , num(date(DATE_STA:"%Dz")))
endCal!.add(Calendar.MONTH, num_of_month_to_add )
endYear=int(endCal!.get(Calendar.YEAR))
endMonth=int(endCal!.get(Calendar.MONTH) + 1)
endDay=int(endCal!.get(Calendar.DATE))
DATE_END = jul(endYear, endMonth, endDay)
fi
fi
?DATE_STA
?DATE_END
?DATE_END-FIN_DATE_STA

Benefit from the best Windows Desktop app in the world and use Strokey.Net!

Keine Kommentare:

Kommentar posten