Unexpected Date conversion

Hello,

well, this is the case, when software should not be too smart :smiley:

I have a following script:

console.log(response.date);
pm.collectionVariables.set("Created_Document_Creation_Date", response.date);
console.log(pm.variables.get("Created_Document_Creation_Date"));

Here is an output:

2023-01-01T05:50:50+01:00
2023-01-01

If I change the variable name to ā€˜Document_Creation_Date’ (I’ve tried 4-5 different names) the output changes to:

2023-01-01T05:50:50+01:00
2023-01-01T05:50:50+01:00

Hey @vadimlammcgm :waving_hand:t2:

Welcome to the Postman Community :postman:

Do you have any variables set with the same name at a different scope (global, environment)?

Do you see the same if you do:

console.log(response.date);
pm.collectionVariables.set("Created_Document_Creation_Date", response.date);
console.log(pm.CollectionVariables.get("Created_Document_Creation_Date"))

Ohhh… it was quite stupid :smiley:

There was a variable in the environment scope… Thanks for the advise!

1 Like

Glad to see you got it sorted. :trophy:

If a variable with the same name is declared in two different scopes, the value stored in the variable with narrowest scope will be used. For example, if there is a ā€œusernameā€ global variable and a ā€œusernameā€ local variable, the local value is used when the request runs.