Getting row by current day from databases

Alex2012

Member
Licensed User
Longtime User
Dim Cursor1 As Cursor
Cursor1 = SQL1.ExecQuery2("SELECT col1, col2, col3, col4 FROM moja13 WHERE _id = '1357862400' ",Null)
For i = 0 To Cursor1.RowCount - 1

This is working

But I need get records daily like that:
DateTime.SetTimeZone(0)
Dim Date, time As Long
Dim date1 As Long
Date = DateTime.now
time = Date Mod DateTime.TicksPerDay
date1 = ((Date - time)/ 1000)
Dim Cursor1 As Cursor
Cursor1 = SQL1.ExecQuery2("SELECT col1, col2, col3, col4 FROM moja13 WHERE _id = 'date1' ",Null)
For i = 0 To Cursor1.RowCount - 1 Its not working I
I am looking for an answer for two days now and I'm starting to get nervous.
Sorry I'm a novice, but I can find answer for that .
Already I've done a lot of test .I need find record from the database every day automatically by current day.:BangHead::BangHead::BangHead::BangHead:
Thankyou for Help
 

mc73

Well-Known Member
Licensed User
Longtime User
Try replacing 'date1' with a ? And null with array as string(date1)
 
Upvote 0

Alex2012

Member
Licensed User
Longtime User
Is not working
I get error:
Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1}
When I did like that:
Sub Date As String
DateTime.DateFormat = "yyyy/MM/dd"
MyDateDay = DateTime.Date(DateTime.Now)
Return MyDateDay
Dim lvd() As String
lvd= MyDateDay

Cursor1 = SQL1.ExecQuery2("SELECT col1, col2, col3, col4 FROM moja13 WHERE Dzien= ?",lvd(MyDateDay)%)
"Error description: Input string was not in a correct format.




Cursor1 = SQL1.ExecQuery2("SELECT col1, col2, col3, col4 FROM moja13 WHERE Dzien= ?","lvd(MyDateDay)%")

Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1}


:BangHead::BangHead::BangHead::BangHead::BangHead::BangHead::BangHead:
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
You need something like this, assuming Dzien is a field in your table that is something like yyyy/MM/dd to match the search:
B4X:
Dim MyDateDay As String
DateTime.DateFormat = "yyyy/MM/dd"
MyDateDay = DateTime.Date(DateTime.Now)  'returns today's date as 2013/01/01
Cursor1 = SQL1.ExecQuery2(("SELECT col1, col2, col3, col4 FROM moja13 WHERE Dzien= ?"),Array As String(MyDateDay))
 
Upvote 0

Alex2012

Member
Licensed User
Longtime User
Thank you worked perfectly
even when I change to the Unix
Thank you again


Dim date1 As String
DateTime.SetTimeZone(0)
Dim date, time As Long'Dim date1 As Long
Dim date2 As Long
date = DateTime.now
time = date Mod DateTime.TicksPerDay
date1 = ((date - time)/ 1000)


Only log for date1 show
"1.3569984E9"

not as previously
"1356998400'
not as previously "1356998400"

:icon_clap::icon_clap::icon_clap::icon_clap::sign0098:
 
Upvote 0
Top