Delete files in a date condition

Delete files before 1st of previous month.

#!/bin/sh

dir_to_check='/root/temp/somedir'

last_month=$(date -d "-1 month -$(($(date +%d)-1)) days" +%Y-%m-%d)

find "$dir_to_check" ! -newermt "$last_month" -type f -exec rm {} \;

find <dir> -type f -mtime +31 -exec rm {} \;

How to delete files before 1st of previous month