B4J Question [ABMaterial] Retrieving & Saving DateTime Values Using ABMDatePicker Help Please!!!

Mashiane

Expert
Licensed User
Longtime User
Hi there

My current database has data time saved as a string in yyyy-MM-dd HH:mm format, however to display this properly in the DateTimePicker I understand one should use YYYY-MM-DD HH:mm

How can I ensure that what is retried in my current database format displays correctly in the DatePicker and how do I ensure that what is saved is also saved correctly in the db format?

Thanks.
 

mindful

Active Member
Licensed User
use this code to change the date format from one to another:
B4X:
Sub ConvertDate(DateTimeString As String, DateTimeFormat As String, NewDateTimeFormat As String) As String
  Dim rememberMyFormat As String = DateTime.DateFormat
  DateTime.DateFormat = DateTimeFormat
  Dim ticks As Long = DateTime.DateParse(DateTimeString)
  DateTime.DateFormat = NewDateTimeFormat
  Dim newDate As String = DateTime.Date(ticks)
  DateTime.DateFormat = rememberMyFormat
  Return newDate
End Sub

Hope this helps !
 
Upvote 0
Top