Android Question Another Date Picker

sparks9941

Member
Licensed User
Longtime User
How can I add 1 year to the date that is picked in Another Date Picker and put the result in a label text
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim per As Period
per.Years = 1
newtime = DateUtils.AddPeriod(timefromDatepicker,per)
Label1.Text = DateTime.Date(newtime)
 
Upvote 0

sparks9941

Member
Licensed User
Longtime User
Thank you, but could you be a little more specific, i am new to this.
Do I need to declare newtime as ?
(timefromDatepicker,per) is timefromDatepicker anotherdatepicker.getdate?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
B4X:
Dim per As Period
dim newtime as long
per.Years = 1
newtime = DateUtils.AddPeriod(anotherdatepicker.getdate,per)
Label1.Text = DateTime.Date(newtime)
 
Upvote 0

sparks9941

Member
Licensed User
Longtime User
Thank you, where would I declare this code. My label just says 12/31/1970 and doesn't change when i select another date from anotherdatepicker
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Here is a small example that has 3 labels: One label to show picker, one label to add 1 year and a label to hold the final date with the year added. I hope it helps:
 

Attachments

  • DatePicketAddOneYear.zip
    11.7 KB · Views: 327
Upvote 0
Top