DateDialog Problem

JMB

Active Member
Licensed User
Longtime User
Hi all

Got a problem with DateDialog.

If I run the MsgBox line shown below it returns "3 5 2011" - correct, 3rd May 2011

But when I show the date dialog (dateFlightDate), it shows the month as June, and I can't figure out why.

What am I missing?

JMB



Msgbox(DateTime.GetDayOfMonth(DateTime.Now) & " " & DateTime.GetMonth(DateTime.Now) & " " & DateTime.GetYear(DateTime.Now),"")

'Set the date for the DateDialog
dateFlightDate.SetDate(DateTime.GetDayOfMonth(DateTime.Now), DateTime.GetMonth(DateTime.Now), DateTime.GetYear(DateTime.Now))
 

agraham

Expert
Licensed User
Longtime User
It's a bug, because Android counts months from 0 to 11 instead of 1 to 12 like Basic4android DateTime. Use the individual properties like the demo does. Month compensates for the difference by subtracting one from the supplied value but I overlooked doing it for the month parameter in SetDate.

B4X:
   Dd.Year = DateTime.GetYear(DateTime.Now)
   Dd.Month = DateTime.GetMonth(DateTime.Now)   
   Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
 
Upvote 0
Top