# How to set env variables 'Date from'? The same date can't be run twice or more. The date can be -+ 1 day

**URL:** <https://community.postman.com/t/how-to-set-env-variables-date-from-the-same-date-cant-be-run-twice-or-more-the-date-can-be-1-day/42742>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [January 10, 2023, 1:49pm UTC](https://community.postman.com/t/how-to-set-env-variables-date-from-the-same-date-cant-be-run-twice-or-more-the-date-can-be-1-day/42742 "2023-01-10T13:49:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maria2812](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@maria2812](https://community.postman.com/u/maria2812)\
**Post date:** [January 10, 2023, 1:49pm UTC](https://community.postman.com/t/how-to-set-env-variables-date-from-the-same-date-cant-be-run-twice-or-more-the-date-can-be-1-day/42742/1 "2023-01-10T13:49:46Z")

</div>

**Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-just-getting-started-category/37) before creating a new topic.**

> Here’s an outline with best practices for making your inquiry.

_My question_:

_Details (like screenshots)_:

_How I found the problem_:

_I’ve already tried_:var now = new Date();  
var timestamp = now.toISOString();  
pm.environment.set(“timestamp”, timestamp);

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 10, 2023, 4:59pm UTC](https://community.postman.com/t/how-to-set-env-variables-date-from-the-same-date-cant-be-run-twice-or-more-the-date-can-be-1-day/42742/2 "2023-01-10T16:59:52Z")

</div>

Can you please clarify what you are asking?

It’s unclear what you need help with.

Just to note, the timestamp that you have currently set is just that, a timestamp, not just the date.

It includes the seconds and minutes. Therefore is likely to be unique unless you run the request more that once in exactly the same second.

---

<div class="post-metadata">

**Author:** ![maria2812](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@maria2812](https://community.postman.com/u/maria2812)\
**Post date:** [January 10, 2023, 8:01pm UTC](https://community.postman.com/t/how-to-set-env-variables-date-from-the-same-date-cant-be-run-twice-or-more-the-date-can-be-1-day/42742/3 "2023-01-10T20:01:53Z")

</div>

> [@michaelderekjones](#):
>
> Therefore is likely to be unique unless you run the request more that once in exactly the same second

Thanks for response!  
Date should be different for every running. It’s not important if it will be 2 days ago or 5 days before current date.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 11, 2023, 10:35am UTC](https://community.postman.com/t/how-to-set-env-variables-date-from-the-same-date-cant-be-run-twice-or-more-the-date-can-be-1-day/42742/4 "2023-01-11T10:35:15Z")

</div>

At the moment, you have the date including the minute and second, therefore it will most likely be unique.

Do you need it to just be a date? yyyymmdd for example? What format does it need to be in? Postman includes the moment library, which allows you to format dates.

If you just do a random variable for a date up to five days ago, its not really a big enough sample, so quite likely to produce the same date on occasion.

If you can only go back five days, then it sounds like you can only run this five times. You can only guarantee the uniqueness five times and would have to include an IF statement as a pre-request script that checks the current date and sets it accordingly.

I guess this depends on how often is this going to be run?
