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

Discussion in 'Code Snippets' started by fredo, May 10, 2019.

Similar threads

B4A Code Snippet Convert timestamp date to Brasil format
B4A Question Unparseable date
B4A Question Time formatting problem
B4A Question add date and time to label
B4A Question automatic launch
  1. fredo

    fredo Active Member Licensed User

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

    Code:
    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
     
    Pencil3, Erel and peacemaker like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice