<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_vals_between_times(dataset_id, start_time, end_time, timestep,increment,**kwargs):
 """ Retrive data between two specified times within a timeseries. The times need not be specified in the timeseries. This function will 'fill in the blanks'. Two types of data retrieval can be done. If the timeseries is timestamp-based, then start_time and end_time must be datetimes and timestep must be specified (minutes, seconds etc). 'increment' reflects the size of the timestep -- timestep = 'minutes' and increment = 2 means 'every 2 minutes'. If the timeseries is float-based (relative), then start_time and end_time must be decimal values. timestep is ignored and 'increment' represents the increment to be used between the start and end. Ex: start_time = 1, end_time = 5, increment = 1 will get times at 1, 2, 3, 4, 5 """

    try:
        server_start_time = get_datetime(start_time)
        server_end_time   = get_datetime(end_time)
        times = [server_start_time]

        next_time = server_start_time
        while next_time < server_end_time:
            if int(increment) == 0:
                raise HydraError("%s is not a valid increment for this search."%increment)
            next_time = next_time  + datetime.timedelta(**{timestep:int(increment)})
            times.append(next_time)
    except ValueError:
        try:
            server_start_time = Decimal(start_time)
            server_end_time   = Decimal(end_time)
            times = [float(server_start_time)]

            next_time = server_start_time
            while next_time < server_end_time:
                next_time = float(next_time) + increment
                times.append(next_time)
        except:
            raise HydraError("Unable to get times. Please check to and from times.")

    td = db.DBSession.query(Dataset).filter(Dataset.id==dataset_id).one()
    log.debug("Number of times to fetch: %s", len(times))

    data = td.get_val(timestamp=times)

    data_to_return = []
    if type(data) is list:
        for d in data:
            if d is not None:
                data_to_return.append(list(d))
    elif data is None:
        data_to_return = []
    else:
        data_to_return.append(data)

    dataset = JSONObject({'data' : json.dumps(data_to_return)})

    return dataset