Hi all,
I'm trying to manage/decide how to store dates and times in my barcode app. The data is stored in a tablet SQLite db. Eventually, the data will then have to be JSON'd to a SQL Server database, thru a web service.
Questions:
Should I store in integer Ticks or text as: yyyyMMdd HHMMSS?
Which format is preferred?
(Sorting is no problem in both formats)
How does one set the data in the correct format for:
- storing?
- fetching?
- date and time format for display?
I've played with some Subs to manage all this, but there's gotta be a simpler way to manage B4A/SQLite dates and times.
If anyone has thoughts on this, or can point me to existing resolutions, I would be grateful.
Thanx,
Mark S.
BTW, I think I found a bug in this function I created.
The returning value is different than the incoming value.
They should be the same.
I'm trying to manage/decide how to store dates and times in my barcode app. The data is stored in a tablet SQLite db. Eventually, the data will then have to be JSON'd to a SQL Server database, thru a web service.
Questions:
Should I store in integer Ticks or text as: yyyyMMdd HHMMSS?
Which format is preferred?
(Sorting is no problem in both formats)
How does one set the data in the correct format for:
- storing?
- fetching?
- date and time format for display?
I've played with some Subs to manage all this, but there's gotta be a simpler way to manage B4A/SQLite dates and times.
If anyone has thoughts on this, or can point me to existing resolutions, I would be grateful.
Thanx,
Mark S.
BTW, I think I found a bug in this function I created.
The returning value is different than the incoming value.
They should be the same.
B4X:
Sub ConvertDateTime(sDateTime As String) As String
'sDateTime incoming format: yyyyMMdd HHMMSS
'sDateTime incoming value : '20171231 091011'
'Idea of this Sub is to convert the format of incoming sDateTime to a display format
'Hence switching of the DateFormat and TimeFormat
DateTime.DateFormat = "yyyyMMdd"
DateTime.TimeFormat = "HHMMSS"
Dim DateTimeParts() As String
DateTimeParts = Regex.Split(" ",sDateTime)
Dim sDate As String = DateTimeParts(0)
Dim sTime As String = DateTimeParts(1)
Dim sDateTimeTicks As Long = DateTime.DateTimeParse(sDate,sTime)
DateTime.DateFormat = "MM/dd/yyyy"
DateTime.TimeFormat = "HH:MM:SS"
'conversion of the date and time values are incorrect:
'Returning Date Value = 09/30/2018 (different from incoming)
'Returning Time Value = 09:09:11 (different from incoming)
Return DateTime.Date(sDateTimeTicks) & " " & DateTime.Time(sDateTimeTicks)
End Sub