How to set DateFormat from DateDialog

sally3599

Member
Licensed User
Longtime User
I need to set the DateFormat to yyyy-mm-dd , but the string from DateDialog still uses yyyy-m-d.

B4X:
Sub Button1_Click
   Dim Dd As DateDialog
   Dim thedate As String
   
   Dd.Year = DateTime.GetYear(DateTime.Now)
   Dd.Month = DateTime.GetMonth(DateTime.Now)   
   Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
   ret = Dd.Show("Set the required date", "Date Dialog", "OK", "Cancel", "", Bmp)
   thedate = Dd.Year & "-" & Dd.Month & "-" & Dd.DayOfMonth
   DateTime.DateFormat = "yyyy-mm-dd"
   
   Label1.Text= thedate
End Sub

How can I set the return DateFormat to yyyy-mm-dd from DateDialog?
Any help will be appreciate it.
 

Mahares

Expert
Licensed User
Longtime User
Use this:
B4X:
thedate=Dd.Year & "-" & NumberFormat(Dd.month,2,0) & "-" &  NumberFormat(Dd.DayOfMonth,2,0)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…