def dateToInt(date, strfmt='%Y%m%d'):
    """ Converts a datetime date into int
    Parameters:
    -----------
        date : datetime
            date in datetime format
        strfmt : string
            format in which the int date will be generated
    Example:
        dateToInt(dt.date(2015,10,23),'%Y')
    """
    return int(date.strftime(strfmt))