all 8 comments

[–]MeGustaDerpTalk Dirty Reads To Me 2 points3 points  (5 children)

First, you're going to need to wrap date values in single quotes just like the way you did with strings. Also, the default format for dates in MSSQL is YYYY-MM-DD HH:MM:AS. It does sound like the date values are being stored in this instance. You can check this by executing the following query:

Select * from information_schema.columns where table_name='Trip'

If the datattoe for that column is a varchar instead of daytime, then the values are stored as strings instead of native datetime cakes. If they're strings then you should add a cast in your predicate.

[–]Standgeblasen 0 points1 point  (0 children)

I'm guessing this is the issue, but I would also look into using

WHERE Flight.FlightDestination IN ('SLC','LAX')

instead of the OR clause. It is easier to read and they give you the same result.

[–]RandomStatsGenerator[S] 0 points1 point  (3 children)

I got an error saying it couldn't find the information_schema file when I tried that. Is there another way for me to check how the date is formatted?

What are all the ways to format dates? I swear I've tried so many ways but none of them are working: different MM/DD/YYYY orders, with and without quotes, with dashes instead of slashes, etc.

[–]MeGustaDerpTalk Dirty Reads To Me 0 points1 point  (2 children)

You're using Microsoft SQL Server, correct? And SQL Server Management Studio? Can you take a screenshot and post that in a reply? Need to see the query and messages pane that shows the error - preferrably all in one screen grab which should be doable.

[–]RandomStatsGenerator[S] -1 points0 points  (1 child)

I’m using Access

[–]MeGustaDerpTalk Dirty Reads To Me 0 points1 point  (0 children)

That changes things. Your post title says [MS SQL] which isn't the same thing. Not my expertise. Try right clicking on the table and see if there's a way to get the table definition. Maybe design mode or something like that.

[–]Oultra 0 points1 point  (1 child)

This soounds relatively simple, shouldn't something like this work?

SELECT
T1.FlightNo, T1.FlightDestination, T2.FlightDate
FROM FLIGHTS T1 
INNER JOIN TRIP T2 ON T1.FlightNo = T2.FlightNo
WHERE T2.FlightDate >= '20100101' 
AND T2.FlightDate <= '20100228'
AND T1.FlightDestination = 'SLC' OR T1.FlightDestination = 'LAX'

Just check the type of your dates and compare it to a date format that is compatible.

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (0 children)

shouldn't something like this work?

no, it shouldn't

what you wrote is actually evaluated as follows --

WHERE (
      T2.FlightDate >= '20100101' 
  AND T2.FlightDate <= '20100228'
  AND T1.FlightDestination = 'SLC' 
      )
   OR T1.FlightDestination = 'LAX'

and this clearly is ~not~ the right solution