# Need yesterday's date in a playbook

**URL:** <https://forum.ansible.com/t/need-yesterdays-date-in-a-playbook/35248>\
**Category:** AWX Project\
**Created:** [May 28, 2021, 5:40pm UTC](https://forum.ansible.com/t/need-yesterdays-date-in-a-playbook/35248 "2021-05-28T17:40:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaleb\_S](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@Kaleb\_S](https://forum.ansible.com/u/Kaleb_S)\
**Post date:** [May 28, 2021, 5:40pm UTC](https://forum.ansible.com/t/need-yesterdays-date-in-a-playbook/35248/1 "2021-05-28T17:40:49Z")

</div>

I have a need to run a playbook using yesterday’s date as a variable in the playbook…

I had a thought to have two scheduled jobs…one to set a fact with the date the job is running, then use that on the next scheduled job, but I’m not entirely sure if that’s the best way when really I just need to have a way to find yesterday’s date in an ansible playbook.

---

<div class="post-metadata">

**Author:** ![Patrick\_Dreher](https://avatars.discourse-cdn.com/v4/letter/p/aca169/32.png) [@Patrick\_Dreher](https://forum.ansible.com/u/Patrick_Dreher)\
**Post date:** [May 28, 2021, 6:01pm UTC](https://forum.ansible.com/t/need-yesterdays-date-in-a-playbook/35248/2 "2021-05-28T18:01:50Z")

</div>

first off this Google Group is about discussing AWX/Tower - not Ansible.

having said that - how about using the shell module to run the date command and registering the output?

- name: Get timestamp from the system  
shell: “date --date=‘1 days ago’”  
register: tstamp

might need to change the command a bit to get the kind of date format you need. for wherever you’ll use it.

---

<div class="post-metadata">

**Author:** ![Kaleb\_S](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@Kaleb\_S](https://forum.ansible.com/u/Kaleb_S)\
**Post date:** [May 28, 2021, 8:14pm UTC](https://forum.ansible.com/t/need-yesterdays-date-in-a-playbook/35248/3 "2021-05-28T20:14:52Z")

</div>

Thanks Patrick,

I apologize for hijacking the group, but appreciate the pointers.

Regards,

Kaleb
