title: Bring startDate and endDate inside a statement in Python in a delta table
body: <p><strong>cmd1</strong></p>
  <pre><code>from pyspark.sql.functions import *
  import datetime
  import pyspark.sql.functions as F
  from pyspark.sql.types import *
  from pyspark.sql.functions import udf
  </code></pre>
  <p><strong>cmd2</strong></p>
  <pre><code>if getArgument('startDate') == '':
    startDate = datetime.datetime.now().date() - datetime.timedelta(1)
    endDate = datetime.datetime.now().date() - datetime.timedelta(1)
    print(startDate, endDate)
  else:
    startDate = getArgument('startDate')
    endDate = getArgument('endDate')
    print(startDate, endDate)
  </code></pre>
  <p><strong>cmd3</strong></p>
  <pre><code>cache table points0 as
  select transactionId,
    period_dt
  from 
  where
  </code></pre>
  <h2>Getting stuck here. I found in databricks for doing a &quot;manual&quot; overwrite follow:</h2>
  <pre><code>df.write \
    .format(&quot;delta&quot;) \
    .mode(&quot;overwrite&quot;) \
    .option(&quot;replaceWhere&quot;, &quot;start_date &gt;= '2017-01-01' AND end_date &lt;= '2017-01-31'&quot;) \
    .save(&quot;/tmp/delta/events&quot;)
  </code></pre>
  <h2>cmd 6 What I am using</h2>
  <pre><code>pDF = spark.sql('select * from points')
  pDF.write.partitionBy('period_dt').format(&quot;delta&quot;).mode(&quot;append&quot;).save('')
  pDF.write.partitionBy('period_dt').format(&quot;delta&quot;).mode(&quot;overwrite&quot;).option(&quot;replaceWhere&quot;, statement).save('')
  </code></pre>
  <h2>cmd 5 I need help in here</h2>
  <p>##I can't think the logical bellow, needs change and I believe the insert also of the startDate and endDate.</p>
  <pre><code>statement = &quot;period_dt = '{}'&quot;.format(current_date)
  print(statement)
  </code></pre>