def convert(value, row):
    key = key_as_str(value)
    
    if not key:
        row['sntyr'], row['sntmo'], row['sntda'] = 9999, 99, 99
        return value
    
    try:
        v = key.replace('-', '')
        assert(len(v) == 8)
        assert(1850 <= int(value[:4]) <= date.today().year)
        dt = strptime(v, '%Y%m%d')
        row['sntyr'], row['sntmo'], row['sntda'] = dt[0], dt[1], dt[2]
        
    except AssertionError:
        row['sntyr'], row['sntmo'], row['sntda'] = 9999, 99, 99
        log.write('sntdt', [row['id'], row['rapstatex'], value, "invalid date"])
        
    return value