Getting the date of the first day of the week
<p>I had a record in a table which contains a date field which will always be the date of the Sunday of a given week.</p>

<p>I would like to query the table so that the records that are returned are in the same week as the week in the date field of the records.</p>

<p>How could I use python's <code>datetime</code> library to achieve this? Thanks.</p>

<p>To get the beginning date of the week:</p>

<pre><code>datetime.today() - timedelta(days=datetime.today().isoweekday() % 7)
</code></pre>

<p>I use this with a filter to get the Sunday date of a record.</p>

python datetime