gsSQL icon indicating copy to clipboard operation
gsSQL copied to clipboard

Date comparison not valid when NON DATE characters are in column.

Open demmings opened this issue 1 year ago • 1 comments

So

=gsSQL("select * from booksales where Date > '5/3/2022' ", "booksales", BookSales!A1:H)

is including records with TEXT CHARACTERS in the Date column. My comparisons to mySQL don't have this issue since I only have DATES in that SQL table. However, sheets can have anything - so I would probably think those records should be skipped.

Note This specific example may not be solvable.
When a comparison is to be made and either side of the logical comparison is an instance of Date, both sides are converted to a JS date. So the problem here is that if a column data in 'Date' is character data and '5/3/22' is character data - a regular ASCII comparison would be made. If however, '5/3/2022' references a CELL (bind variables) - it would be taken to be a date since Sheets would automatically converted it into a JS date

e.g. cell C1 was a date.

=gsSQL("select * from booksales where Date > ?1 ", "booksales", BookSales!A1:H, true, C1)

demmings avatar Mar 25 '24 04:03 demmings

I am leaving this open for now. I need some more real world testing - rather than just my TDD tests. Dates in general have more things that can go wrong. More testing is need for any function that uses dates and data in the sheets is not perfect.

demmings avatar Mar 28 '24 23:03 demmings