Android Code Snippet [SQL] Convert DateTimeString "dd.mm.YYYY HH:MM" to Android DateTimeLongValue

Code to convert a given DateTimeString in "dd.mm.YYYY HH:MM" format within an SQLite statement to an Android LongValue in ms.

B4X:
strftime('%s', substr(estart,7,4)||'-'||substr(estart,4,2)||'-'||substr(estart,1,2)||' '||substr(estart,12,5), 'utc') *1000 AS xLongValueFromGivenDateString

While B4X provides sufficient DateTime functions for use in B4X code, it may be necessary to convert externally generated timestamps to the Android format.

The reason for this snippet was the use case that all rows of a large table delivered from outside must be given a LongValue in a single SQLite preparation step.

2019-05-10_16-02-58.jpg
 
Top