Looking at the hill of indents seems like this can be improved
As we do not know the task given we cannot fully review. While the code itself looks reasonable there is some smell.
date
To me it is very smelly, that a function named id() returns a date
start_date = ids('DIR', '348')

This is also requiring a switch inside your function, so most probably there are two functions intermingled that should not be.
data structure
list() is a bad structure to search in. While this may be the data format you read or get passed, you most probably should convert it to a structure allowing direct lookup (converting once). The description of the current structure is missing, also we do not know if there are other functions accessing the data.