from datetime import datetime


def isdate(s_date: str, if_nan=False):
    """Check whether the date string is yyyymmdd format or not."""
    if len(s_date) != 8:
        return False
    try:
        datetime.strptime(s_date, "%Y%m%d")
        return True
    except ValueError:
        return False
    except TypeError:
        return if_nan