B4J Question B4XTable, search by date?

G-ShadoW

Active Member
Licensed User
Longtime User
How to use B4XTable and searchfield ( search by date ) ?
Date Value are saved as ticks, (1652824800000 = 05/18/2022 ) ... search using MM/dd/yyyy or 1652824800000 ticks not working.
Any suggestion?

I have just checked at www.unixtimestamp.com
given tick value shows current saved item with yesterday's datum

B4X:
Format    Milliseconds (1/1,000 second)
GMT    Tue May 17 2022 22:00:00 GMT+0000
Your Time Zone    Wed May 18 2022 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)
Relative    18 hours ago
 
Last edited:

Magma

Expert
Licensed User
Longtime User
Sorry, this is only for show - and sort:

also... when setup it...
B4X:
...
b4xtable1.AddColumn("date-title-col",  b4xtable1.COLUMN_TYPE_DATE)
...

after setupping like that.... i give it's value (parsing) like "ticks"...

A solution that already do at mine b4xtables... is an extra search textfield... that searching direct the db... So is using ticks for showing into b4xtable... but when I want to search something I search db-table and show only specific rows... (but this only an idea - may be not works for you)
 
Last edited:
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
For input data in table I use preferences dialog and there is problem because ...
If I add new record to table using preferences dialog and Table Column ( B4XTable.COLUMN_TYPE_DATE ) it shows
wrong tick value so this option will not work ( unless I input time ticks like item.Put("key", date_string ... )

ticks value is 18h old at the moment you save it ( see 1st post ) at least that's what I see on my PC
( maybe problem is in preferences dialog and some date format or how it set ticks, don't know and for now also less important )

will save it as txt string so search option will work for date also.
B4X:
B4XTable.AddColumn("Datum", B4XTable.COLUMN_TYPE_TEXT)

B4X:
Private Sub ShowDialog(Item As Map, RowId As Long)
...
Dim date_string As String
    DateTime.DateFormat = "MM/dd/yyyy"
    date_string=DateTime.Date(DateTime.Now)
params.AddAll(Array(Item.Get("Model"), Item.Get("Name"), Item.Get("Datum"), .... 'remove'

params.AddAll(Array(Item.Get("Model"), Item.Get("Name"), date_string,.... 'add'

' or item.Put("Datum",date_string)'

Thank you for suggestion and possible solutions.
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
...If you passed the values/parameters into b4xtable (with column b4xtable1.COLUMN_TYPE_DATE)...

i don't think you ll have problem at showing... using DateTime.DateParse(stringitemyoutakefromanywhere)

but for search as you said.. you must think the way different... may be you can have a column hidden (width:1) with string date too.. (another solution if you don't want an extra textfield for search)

at preferences dialog if using Date Field (Erel's Form Builder json) you set it with ticks for example: (options.put("keyname",datetime.now)
 
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
...

at preferences dialog if using Date Field (Erel's Form Builder json) you set it with ticks for example: (options.put("keyname",datetime.now)

At this point with preferences dialog and date picker ( options.put("keyname",datetime.now) is also not an option, what if user select 'daytime.now <> 2 days ... Ticks value will be saved with time you have entered New values...

Date picker is useless at that point.
 
Upvote 0

G-ShadoW

Active Member
Licensed User
Longtime User
I know that daytime.now show tick value, but like a wise man said, simplicity is the key :)
also extra search field as an option, thank you @Magma
 
Upvote 0
Top