Forum > Database

[SOLVED]DATASET Doesn't Filter as Expected

<< < (2/14) > >>

Zvoni:

--- Quote from: kito on July 18, 2023, 09:30:07 am ---Hello Zvonic
I am using sqlite database, resumption is vchar, I am not facing any problem  using the  filter expression but it behave strangely when it comes  to the date that muchs the weekend. where I can't filter the dataset matching DateTimePicker.Date, but I must select a specific date(end+1 day)in order to see the results(end+2 days) The strange thing is that the date selected in the DateTimePicker is completely different from the results shown in the filtered dataset.

--- End quote ---
Wait a sec:
First: Which Format for your dates are you using in the SQLite-DB? I hope it's ISO-Format "YYYY-MM-DD"
Next: Have you checked that DateToStr returns the SAME Format?

I really, really hope you use ISO-Format

.....and there is no vchar DataType in SQLite.
It's TEXT.
Period

EDIT:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TDataModule1.DatasetCalcFields(DataSet: TDataSet);  begin if  (DayOfWeek(    END )=6 )then    resumption  := IncDay(END,2)   else resumption  := IncDay(END,1)  end;If resumption is of type TEXT (vchar), you do realize that IncDay returns a DateTime? And you're assigning without Formating!
--> https://www.freepascal.org/docs-html/rtl/sysutils/formatdatetime.html
I'm more surprised this compiles.....

kito:

--- Quote from: Zvoni on July 18, 2023, 09:53:12 am ---
Wait a sec:
First: Which Format for your dates are you using in the SQLite-DB? I hope it's ISO-Format "YYYY-MM-DD"
Next: Have you checked that DateToStr returns the SAME Format?

I really, really hope you use ISO-Format

.....and there is no vchar DataType in SQLite.
It's TEXT.
Period


I'm more surprised this compiles.....

--- End quote ---
to avoid facing a problem with date encoding especially when I copy my program from one computer to another. Which naturally varies the date encoding, especially in the order of the day and the year  Therefore, I use the following solution/trick:
In the database: the field type is set as text/varchar,
 but in the program, I manually add a field to the dataset and assign it as a date type. Then, I link it to the relevant field, so the program handles it as a DateTime type
So I don't I have to worry about date time Format  issues .

alpine:

--- Quote from: kito on July 18, 2023, 12:53:51 pm ---to avoid facing a problem with date encoding especially when I copy my program from one computer to another. Which naturally varies the date encoding, especially in the order of the day and the year  Therefore, I use the following solution/trick:
In the database: the field type is set as text/varchar,
 but in the program, I manually add a field to the dataset and assign it as a date type. Then, I link it to the relevant field, so the program handles it as a DateTime type

--- End quote ---
And who is making the TDateTime<-->Text conversions between the 'linked' fields?


--- Quote from: kito on July 18, 2023, 12:53:51 pm ---So I don't I have to worry about date time Format  issues .

--- End quote ---
You should, obviously.

Giving such kind of 'pseudo code' doesn't help. Consider a small project to demonstrate your issue.

Zvoni:

--- Quote from: kito on July 18, 2023, 12:53:51 pm ---
--- Quote from: Zvoni on July 18, 2023, 09:53:12 am ---
Wait a sec:
First: Which Format for your dates are you using in the SQLite-DB? I hope it's ISO-Format "YYYY-MM-DD"
Next: Have you checked that DateToStr returns the SAME Format?

I really, really hope you use ISO-Format

.....and there is no vchar DataType in SQLite.
It's TEXT.
Period


I'm more surprised this compiles.....

--- End quote ---
to avoid facing a problem with date encoding especially when I copy my program from one computer to another. Which naturally varies the date encoding, especially in the order of the day and the year  Therefore, I use the following solution/trick:
In the database: the field type is set as text/varchar,
 but in the program, I manually add a field to the dataset and assign it as a date type. Then, I link it to the relevant field, so the program handles it as a DateTime type
So I don't I have to worry about date time Format  issues .

--- End quote ---

What utter non-sense.
Use ISO-Format "YYYY-MM-DD" in the Database, and any Date-Representation in your Frontend "converted" to that same ISO-Format in the background before writing/reading to/from the Database.
The ISO-Format WAS "invented" to address exactly the problem of "localized" Date-Representations

kito:


--- Quote ---And who is making the TDateTime<-->Text conversions between the 'linked' fields?
--- End quote ---

 I don't know how but as long as  I respect the date format every thing is fine.



--- Quote ---You should, obviously.
--- End quote ---
:(


--- Quote ---Giving such kind of 'pseudo code' doesn't help. Consider a small project to demonstrate your issue.
--- End quote ---

good idea! thanks  here you are :

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version