SELECT "Trade Details 2".Portfolio,
"Trade Details 2".CONTRACT_ID,
"Trade Details 2".START_DATE,
"Trade Details 2".MATURITY_DATE,
"Trade Details 2".NOTIONAL1,
"Trade Details 2".CONTRACT_NPV,
"Trade Details".TERM
FROM "Trade Details 2"
JOIN "Trade Details"
WHERE "Trade Details 2".CONTRACT_ID="Trade Details".FCC_ID and
("Trade Details 2".NOTIONAL1 > "0.0") and
("Trade Details 2".MATURITY_DATE > "20180621")
ORDER BY CONTRACT_ID asc
I'm attempting to fix the date formats for my START_DATE
and MATURITY_DATE
columns in the tables I've joined in this query. The format for the START_DATE
is like: 2018-06-22 00:00:00
, while the MATURITY_DATE
is like: 20180622
. I would like to be able to fix this so both columns are the same format, preferably just 2018-06-22
. I have already tried in python using: input_string='20191217'
start_date=pd.to_datetime(input_string[-2:]+input_string[4:6]+
input_string[:4], dayfirst=True)
but that didn't work, just claiming invalid syntax. Is there a way in SQL or Python to make these two columns have the same date?