### Discussed in https://github.com/apache/airflow/discussions/33345

<div type='discussions-op-text'>

<sup>Originally posted by **vuphamcs** August 11, 2023</sup>
### Description

Is there a variable similar to `prev_start_date_success` but for the previous DAG run’s completion date? The value I’m hoping to retrieve to use within the next DAG run is `2023-08-10 16:04:30`

![image](https://github.com/apache/airflow/assets/1600760/9e2af349-4c3e-47e1-8a1a-9d8827b56f57)


### Use case/motivation

One particular use case is to help guarantee that the next DAG run only queries data that was inserted during the existing DAG run, and not the past DAG run.

```python
prev_ts = context['prev_end_date_success']

sql = f"SELECT * FROM results WHERE created_at > {context['prev_end_date_success']}"
```

### Related issues

_No response_

### Are you willing to submit a PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
</div>
from airflow.models.dagrun import DagRun  
    
    
    
    
    ignore_schedule = state is not None or not dag.timetable.can_be_scheduled
    if dag.catchup is True and not ignore_schedule:
        last_dagrun = DagRun.get_previous_scheduled_dagrun(dr.id, session=session)
    else:
        last_dagrun = DagRun.get_previous_dagrun(dag_run=dr, session=session, state=state)
    if last_dagrun:
        return last_dagrun
    return None
def _get_previous_execution_date(
    *,
    task_instance: TaskInstance | TaskInstancePydantic,
    state: DagRunState | None,
    session: Session,
) -> pendulum.DateTime | None:
    """
    The execution date from property previous_ti_success.
    :param task_instance: the task instance
    :param session: SQLAlchemy ORM Session
    :param state: If passed, it only take into account instances of a specific state.
    :meta private:
    """
    log.debug("previous_execution_date was called")
    prev_ti = task_instance.get_previous_ti(state=state, session=session)
    return prev_ti and pendulum.instance(prev_ti.execution_date)
def _email_alert(