# Pre-execution script - set future dates with api

**URL:** <https://community.dynatrace.com/t/pre-execution-script-set-future-dates-with-api/33145>\
**Category:** Synthetic Monitoring\
**Tags:** synthetic-monitoring\
**Created:** [November 1, 2021, 4:29am UTC](https://community.dynatrace.com/t/pre-execution-script-set-future-dates-with-api/33145 "2021-11-01T04:29:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elaineong](https://avatars.discourse-cdn.com/v4/letter/e/7c8e57/32.png) [@elaineong](https://community.dynatrace.com/u/elaineong)\
**Post date:** [November 1, 2021, 4:29am UTC](https://community.dynatrace.com/t/pre-execution-script-set-future-dates-with-api/33145/1 "2021-11-01T04:29:22Z")

</div>

May I know what was wrong with the commented-out lines?

I am trying to set future dates using API, but it will not work.

//var curdate = new Date();  
//var arriveDate = curdate.getTime() + 5 \* 24 \* 60 \* 60 \* 1000;  
//var departDate = curdate.getTime() + 6 \* 24 \* 60 \* 60 \* 1000;

[//api.setValue](https://api.setValue)(“arrriveDate”, api.dateToFormat(arriveDate, “dd/MM/yyyy”));  
[//api.setValue](https://api.setValue)(“departDate”, api.dateToFormat(departDate, “dd/MM/yyyy”));

// below works

api.setValue(“arriveDate”, “09/11/2021”);  
api.setValue(“departDate”, “10/11/2021”);

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [November 2, 2021, 2:44pm UTC](https://community.dynatrace.com/t/pre-execution-script-set-future-dates-with-api/33145/2 "2021-11-02T14:44:31Z")

</div>

[@elaineong](https://community.dynatrace.com/user/45728),

Nothing seems to be wrong with your lines. Can you try to use api.getValue like below to see the output.

```markup
api.setValue("arrriveDate", api.dateToFormat(arriveDate, "dd/MM/yyyy"));
api.info(api.getValue("arrriveDate"));

```

We have to use&nbsp;**api.getValue()** to get the value of the key previously set by **api.setValue()**.

Regards,

AK
