Using SQL language , trying to pull the same dates as you can see from the code as below;
select aa.sim
from app_date1 aa
left join
app_date2 bb on aa.first_date=bb.start_date and
aa.last_date=bb.end_date
start_date is datetime : 2015-11-09 00:00:00.0000000
end_date is string : Friday, August 25, 2023
how to make this code possible to run
"Using SQL language" isn't quite enough. It is - as you said - a language, but each database has its own flavor, especially when dealing with date values. Functions differ.
For example, in Oracle, this is what you might do.
The best option is to work with dates, not strings. Therefore, convert everything else to valid date values.
Let's presume that
app_date1table'sfirst_dateandend_datecolumns' datatype isdate(as you didn't say different, and their name suggests so).(I'm setting date format so that you'd know what is what; e.g. if you see something like "03.06.2023", is it 3rd of June or 6th of March?) you probably don't have to do that):
As of
end_date, which is stored as a string (note that this was bad decision. Always store dates and timestamps in appropriate datatype columns), you'd applyto_charfunction:As of
start_date- which is a timestamp -castit todatedatatype:It means that final query might look like this:
Once again: if you use different database (such as MySQL or PostgreSQL or MS SQL Server or ...), code will probably be different from what I posted.