Date format in .csv file

Hi Team,
I am using the .csv file for data driven approach whereas wanted to verify the date, How I can achieve in terms of consistent way.

I am using the below method but always need manual intervention.
1.Response file-

{
    "nextScheduledPremierOrder": {

        "scheduledOn": "2020-09-10 03:58:39.000000",
}}
  1. Postman script
pm.test("data verification", function () {
 let jsonData = pm.response.json();
 pm.expect(jsonData.nextScheduledPremierOrder.scheduledOn).to.include((data.nextScheduledPremierOrderscheduledOn));
});
  1. .csv file
    Enter the date in respective column, Format the cell with required format.
    steps
  2. Entering the date whereas bydeafult value can see as 09-10-2020
  3. format the cell with required format that is 2020-09-10

Now if I close the sheet and again run the script it will fail.
can we use any function?

You can utilize moment library to achieve the transformation of dates and then perform your tests over the transformed dates.

@danny-dainton has written a great article around how to use moment in postman: https://dannydainton.com/2018/05/21/hold-on-wait-a-moment/

1 Like

Thanks, Able to utilize date functions from above link.