Just for kicks, I asked ChatGPT your question in this form -
Write a B4X sub that takes a date in the form "MM/DD/YYYY" and a day offset (in days), adds the number of days in the day offset to the given date and return the resulting date as a string.
Here is what he/she came up with -
Sub AddDaysToDate(InputDate As String, DayOffset As Int) As String
Dim sdf As B4XSerializator ' Just to support cross-platform compatibility
Dim DateFormat As String = "MM/dd/yyyy"
Dim DateFormatter As B4XFormatter
DateFormatter.Initialize
DateFormatter.DateFormat = DateFormat
Dim d As Long
Try
d = DateTime.DateParse(InputDate)
Catch
' Fallback if DateParse does not understand the format
Dim parts() As String = Regex.Split("/", InputDate)
If parts.Length <> 3 Then Return "Invalid date format"
Dim month As Int = parts(0)
Dim day As Int = parts(1)
Dim year As Int = parts(2)
d = DateUtils.SetDate(year, month, day)
End Try
Dim newDate As Long = d + DayOffset * DateTime.TicksPerDay
Return DateTime.Date(newDate)
End Sub
Usage Example:
Dim newDate As String = AddDaysToDate("06/23/2025", 10)
Log(newDate) ' Output: 07/03/2025
Have not tried it. I'll let you do that.
Let us know how it works.