I am using SQLite to perform queries on my Table “Todos”
I run on julia the commands:
julia> using SQLite
julia> db = SQLite.DB(“db/dev.sqlite3”)
julia> using DataFrames
From my “Todos” table I want to return values where date > = 2024-10-03
julia> df = DBInterface.execute(db, “SELECT id, category, date FROM todos WHERE date >= 2024-10-03 ORDER BY date” ) |> DataFrame
And I get the result:
Row │ id category date
│ Int64 String Date
─────┼───────────────────────────────
1 │ 25 family 2024-08-10
2 │ 72 other 2024-08-13
3 │ 24 other 2024-08-14
4 │ 47 work 2024-08-14
5 │ 35 learning 2024-08-17
6 │ 42 accounting 2024-08-17
7 │ 52 shopping 2024-08-17
8 │ 6 family 2024-08-18
9 │ 9 work 2024-08-18
10 │ 74 work 2024-08-19
11 │ 61 accounting 2024-08-21
12 │ 63 hobby 2024-08-21
13 │ 50 errands 2024-08-22
14 │ 39 accounting 2024-08-24
15 │ 20 shopping 2024-08-25
16 │ 31 accounting 2024-08-26
17 │ 66 accounting 2024-08-26
18 │ 33 hobby 2024-08-27
19 │ 60 hobby 2024-08-28
20 │ 12 work 2024-08-29
⋮ │ ⋮ ⋮ ⋮
52 │ 7 accounting 2024-10-05
53 │ 45 personal 2024-10-06
54 │ 58 work 2024-10-07
55 │ 32 family 2024-10-08
56 │ 64 work 2024-10-09
57 │ 11 shopping 2024-10-15
58 │ 21 hobby 2024-10-15
59 │ 67 work 2024-10-15
60 │ 8 other 2024-10-21
61 │ 51 hobby 2024-10-23
62 │ 57 other 2024-10-26
...
Why is not giving the correct results?
Do I need some kind of Casting? if yes, which one?
I have tried with the cast : (I actually need to get the values within a date range)
julia> DBInterface.execute(db, "SELECT id, category, date FROM todos WHERE (cast(date as date) BETWEEN ‘2024-10-03’ AND ‘2024-10-27’) ORDER BY date " ) |> DataFrame
and I get 0 results, but I do have values!
0×3 DataFrame
Row │ id category date
│ Int64? String? Missing
─────┴───────────────────────────
Same case when I query with SearchLight:
julia> SearchLight.query("SELECT id, category, date FROM todos WHERE date >= '2024-10-03'")
[ Info: SELECT id, category, date FROM todos WHERE date >= '2024-10-03'
70×3 DataFrame
Row │ id category date
│ Int64 String Date
─────┼───────────────────────────────
1 │ 25 family 2024-08-10
2 │ 72 other 2024-08-13
3 │ 24 other 2024-08-14
4 │ 47 work 2024-08-14
5 │ 35 learning 2024-08-17
6 │ 42 accounting 2024-08-17
7 │ 52 shopping 2024-08-17
8 │ 6 family 2024-08-18
9 │ 9 work 2024-08-18
10 │ 74 work 2024-08-19
11 │ 61 accounting 2024-08-21
12 │ 63 hobby 2024-08-21
13 │ 50 errands 2024-08-22
14 │ 39 accounting 2024-08-24
15 │ 20 shopping 2024-08-25
16 │ 31 accounting 2024-08-26
17 │ 66 accounting 2024-08-26
18 │ 33 hobby 2024-08-27
19 │ 60 hobby 2024-08-28
20 │ 12 work 2024-08-29
⋮ │ ⋮ ⋮ ⋮
52 │ 7 accounting 2024-10-05
53 │ 45 personal 2024-10-06
54 │ 58 work 2024-10-07
55 │ 32 family 2024-10-08
56 │ 64 work 2024-10-09
57 │ 11 shopping 2024-10-15
58 │ 21 hobby 2024-10-15
59 │ 67 work 2024-10-15
60 │ 8 other 2024-10-21
Any suggestions?
Thank you!