Android Question Help me about DatePicker

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.
 

Attachments

universengo

Member
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?
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.
Thanks.
 

universengo

Member
You will need to get the string from the database and parse it.
B4X:
Dim dt As String = rs.GetString(...)
dt = dt.Substring2(0, dt.IndexOf(" "))
Thanks Erel.
I use this code for sqldate Sub in DBUtils Code Module as below:
B4X:
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)
    DateTime.DateFormat=CurrentFormat
    txtDate=mysqlDate
End Sub
then I call this sub as below:

B4X:
Dim t As String
    DBUtils.DateSQL(t,Value)
    Log(t)
But t have got to get data of DateSQL
So log (t) is blank.

Help me how to show t as mysqlDate

Thanks.
 

DonManfred

Expert
Licensed User
B4X:
Public Sub DateSQL(tgian As String) as String
    Dim CurrentFormat As String=DateTime.DateFormat
    DateTime.DateFormat="yyyy-MM-dd HH:mm:ss"
    Dim mysqlDate As String=DateTime.Date(tgian)
    DateTime.DateFormat=CurrentFormat
    return mysqlDate
End Sub
B4X:
Dim t As String = DBUtils.DateSQL(Value)
    Log(t)
I strongly suggest to learn the B4X Syntax and how the codeflow is!
 

universengo

Member
B4X:
Public Sub DateSQL(tgian As String) as String
    Dim CurrentFormat As String=DateTime.DateFormat
    DateTime.DateFormat="yyyy-MM-dd HH:mm:ss"
    Dim mysqlDate As String=DateTime.Date(tgian)
    DateTime.DateFormat=CurrentFormat
    return mysqlDate
End Sub
B4X:
Dim t As String = DBUtils.DateSQL(Value)
    Log(t)
I strongly suggest to learn the B4X Syntax and how the codeflow is!
Thanks DonManfred.

It was SOLVED.
 
Top