Passing date value

Hello there!
I’m trying to pass date through header into postman, but confused about the correct value to send.
I need to retrieve data by month and year.

Thank you!

@theshaden Welcome to the community :partying_face:

Yes date format differs, and for your request do you see any format in your API reference/documentation?

Usually we can get the date using newDate() method or “moment”. And we need to format it before sending it to the headers.

const moment = require('moment');
pm.globals.set("timestamp", moment().format("MM/DD/YYYY hh:mm:ss"));

or

var hdate = new Date();
console.log(hdate);

Kindly provide more details/screenshots to get to understand the issue :blush:

1 Like

Thank you dear @bpricilla . Attached is what I’m working on, and where I’m passing the values. I’m not sure if this is true or no

1 Like

@theshaden Okay I get that. So date depends on your requirement. May be based on the API purpose.

Try changing the dates and check if the response is same or different. In that way you can ensure that the dates filters are working or not :blush:

Unfortunately, I just tried it and it gave me different values.

Okay so the date filters are working then :slight_smile: Ofcourse it should give different values!!

So what’s the confusion here? :wink:

I mean I send it again with same date period (January) and gave me different values.

Oh :disappointed:

Okay, so do we have any info about it in your API documentation? Unless it’s a public API I can get to know about that details :slightly_smiling_face:

It’s not a public API, and what I’ve notice is that it takes date from -to

I think the mistake was that I have to send date values through Params instead of Header

@theshaden Did you tried that way? Usually yes, it will go as part of Params. But this details should be specified in the API documentation.