View Single Post
Old 08-14-2022, 08:48 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,091
Quote:
Originally Posted by Publisher Bucks View Post
This is what I'm using which, from what I have seen online, should be working:


"SELECT * FROM CookingShows WHERE Date BETWEEN '2022-01-09' AND Date '2022-01-10' ORDER BY Date DESC;");

Multiple sites are saying that is the correct format, yet it isnt displaying any data that I have in the table.

Any thoughts?
1. You have the syntax wrong. The correct syntax is "where date between date1 and date2" not "where date between date1 and date date2".

2. You are trying to compare a string to a date. You need to cast the strings as dates if you want a date compare. "where date between cast(date1 as date) and cast(date2 as date)"

3. Date is a keyword in MYSQL and should not be used as a variable name or field name. So where you have your column called date ("where Date...") should be something like "where order_date...." Or whatever other name the date is stored as.


.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote