import time


def dateToDBFmt(strVal, fromFmt="%m/%d/%Y"):
    """Convert a date from the specified fromFmt (a string accepted by time.strptime)
    to "yyyy-mm-dd", the format used by databases.
    """
    try:
        dateTuple = time.strptime(strVal, fromFmt)
    except ValueError:
        raise ValueError("%s not in the specified date format: %s" % (strVal, fromFmt))
    return time.strftime("%Y-%m-%d", dateTuple)