Querying postgresql from Python for DateTime values between two dates
<p>I have the following dateTime text type variable in Postgres table</p>

<pre><code>"2016-05-12T23:59:11+00:00"          
"2016-05-13T11:00:11+00:00"
"2016-05-13T23:59:11+00:00"
"2016-05-15T10:10:11+00:00"
"2016-05-16T10:10:11+00:00"
"2016-05-17T10:10:11+00:00"
</code></pre>

<p>I have to write a Python function to extract the data for a few variables between two dates</p>

<pre><code>def fn(dateTime):
    df1=pd.DataFrame()
    query = """ SELECT "recordId" from "Table" where "dateTime" BETWEEN %s AND %s """ %(dStart,dEnd) 
    df1=pd.read_sql_query(query1,con=engine)
    return df1
</code></pre>

<p>I need to create dStart and dEnd variables and use them as function parameters as below</p>

<pre><code>   fn('2016-05-12','2016-05-15')
</code></pre>

<p>I tried using to_char("dateTime", 'YYYY-MM-DD') Postgres function but didn't work out. Please let me know how to solve this</p>