from datetime import datetime


def date_str_from_datetime_str(datetime_str):
    """Convert a datetime string to a date string, e.g. 2020-07-04 12:00:00 to 2020-07-04"""
    try:
        return datetime.strptime(datetime_str, "%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%d")
    except ValueError:
        return datetime_str