Android Question Help me about DatePicker

Discussion in 'Android Questions' started by universengo, May 9, 2019.

  1. universengo

    universengo Member

    Hello everyone!
    I am a newbje, Please help me.
    I use DButils to load access data (*.accdb file) to tableview.
    But my date is show on table view have time as 2018-05-29 00:00:00.000000 (see picture below) (although in may access date, i have set this field is short date)
    So I have a problem to load this date to my datepicker.
    Please help me how to get data from tableview to show on DatePicker when i click the table.

    Attached Files:

    • date.jpg
      File size:
      155.1 KB
  2. Erel

    Erel Administrator Staff Member Licensed User

    I guess that you are using DBUtils.ExecuteTableView. This method just takes the values as strings and adds them to the TableView.

    Which Jdbc driver are you using? Why are you using an access database instead of a proper database?
  3. universengo

    universengo Member

    Thanks Erel. You are right. I use DBUtils.ExecuteTableView.
    I use these driver:
    ' SQLite driver
    #AdditionalJar: ucanaccess-4.0.4.jar
    #AdditionalJar: hsqldb.jar
    #AdditionalJar: jackcess-2.1.11.jar
    #AdditionalJar: commons-logging-1.1.3.jar
    #AdditionalJar: commons-lang-2.6.jar
    I use an access database instead of a proper database because I have this access file available and I would like to use these table in access file for using mail merge later (as default report). I don't know how data report.

    And the last, How to resolve my situation about use date from table and show on datepicker.
  4. Erel

    Erel Administrator Staff Member Licensed User

    You will need to get the string from the database and parse it.
    Dim dt As String = rs.GetString(...)
    dt = dt.Substring2(
    0, dt.IndexOf(" "))
    universengo likes this.
  5. universengo

    universengo Member

    Thanks Erel.
    I use this code for sqldate Sub in DBUtils Code Module as below:
    Public Sub DateSQL(txtDate As String, tgian As String)
    Dim CurrentFormat As String=DateTime.DateFormat
    DateTime.DateFormat="yyyy-MM-dd HH:mm:ss"
    Dim mysqlDate As String=DateTime.Date(tgian)
    End Sub
    then I call this sub as below:

    Dim t As String
    But t have got to get data of DateSQL
    So log (t) is blank.

    Help me how to show t as mysqlDate

  6. DonManfred

    DonManfred Expert Licensed User

    Public Sub DateSQL(tgian As Stringas String
    Dim CurrentFormat As String=DateTime.DateFormat
    DateTime.DateFormat="yyyy-MM-dd HH:mm:ss"
    Dim mysqlDate As String=DateTime.Date(tgian)
    return mysqlDate
    End Sub
    Dim t As String = DBUtils.DateSQL(Value)
    I strongly suggest to learn the B4X Syntax and how the codeflow is!
    Erel and universengo like this.
  7. universengo

    universengo Member

    Thanks DonManfred.

    It was SOLVED.
  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