Python Forum
[PyQt] to display cotent of database between two dates
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] to display cotent of database between two dates
#14
Yes and if you look at what was printed -- which by the way is what you send to the database as a query -- you can see that the first one (which works) sends a proper SQL Statement -- while the second one does not for the database would not have any way of interpretting what you mean by start_date and end_date especially when its comparing those to a Date field.

I was (1) trying to show you how to validate your SQL Statements and (2) hoping that you would understand the issue once you printed out what it is you are actually sending to the database.

Typically I create my SQL In Code Statements as follows (especially if I am using variables to supply the parameters):
strDbSQL = ''
strDbSQL += 'SELECT * '
strDbSQL += '  FROM correction_loc35R '
strDbSQL += ' WHERE date_correction between '
strDbSQL += start_date.strftime('%m-%d-%Y')
strDbSQL += '   AND '
strDbSQL += end_date.strftime('%m-%d-%Y')
strDbSQL += ' ORDER BY date_correction DESC'
This makes it easy to read and allows for easier insertion of more statements as needed
Reply


Messages In This Thread
RE: to display cotent of database between two dates - by Denni - Jan-03-2020, 04:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Display and update the label text which display the serial value jenkins43 5 9,051 Feb-04-2019, 04:36 AM
Last Post: Larz60+
  Display more than one button in GUI to display MPU6000 Sensor readings barry76 4 3,879 Jan-05-2019, 01:48 PM
Last Post: wuf

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020