from datetime import datetime


def datetime_helper(
        datetime_str
):
    """try to convert datetime for comparison

    Args:
        datetime_str (str): datetime str (%Y-%m-%d) or (%Y-%m-%dT%H:%M:S)

    Returns:
        datetime.datetime

    """
    try:
        return_datetime = datetime.strptime(datetime_str, '%Y-%m-%d')
    except Exception:
        try:
            return_datetime = datetime.strptime(datetime_str, '%Y-%m-%dT%H:%M:%S')
        except Exception:
            raise

    return return_datetime