from datetime import datetime


def convert_date(raw_date: str):
    """
    Convert raw date field into a value interpretable by the dataserver.

    The date filtering API expects mm/dd/YYYYZ format.
    """
    if raw_date.startswith("None"):
        return None
    try:
        date = datetime.strptime(raw_date, "%Y-%m-%d %H:%M:%S")
        return date.strftime("%m/%d/%YZ")
    except ValueError:
        try:
            date = datetime.strptime(raw_date, "%Y-%m-%dT%H:%M:%S.%fZ")
            return date.strftime("%m/%d/%YZ")
        except:
            return None