Manipulating Date returned

 {
"start": 0,
"count": 3,
"data": [
    {
        "companyName": "Company 3",
        "startDate": 1577854800000,
        "endDate": 1593489600000,
        "comments": "- Successfully led the business unit establishing all policy and procedure \n- Negotiated multiple outsourced contracts for suppliers across IT and digital \n- faced off to the business etc "
    },
    {
        "companyName": "Company2",
        "startDate": 1594526400000,
        "endDate": 1612069200000,
        "comments": "- Barry review contracts \n- barry highlighted failed calluses \n- Was in charge of re-writing contracts \n- Reviewed and re negotiated supplier contracts \n"
    },
    {
        "companyName": "Copmpany1",
        "startDate": 1612155600000,
        "endDate": 1617854400000,
        "comments": "- barry ran the asdnjsabndjkaskdjna\n- Barry managed the day to day delivery or lasdjkasndjksnadkjasndsa\n- sahdjasdnjkasdnaksjdas\n- ajsndjaksndjanas\n- asjdajsndja nsdjkasnd\n- asjdjikasndjasnkdjand"
    }
]

}

Dear all, I am looking at building a profile builder from data held in one of our databases. Essentially I am trying to build a list of their work history.

The JSON is what is currently returned when I make my HTTP call.

However I need to convert the date (number) into a string with month - year for example
May - 2001.

However I am struggling to convert the json item into a DateTime Variable.

I have deserialized the json and looping through each record in data.

Assign → startDate = cdate(item(“startDate”).ToString).Date

However, it throws an error when trying to assign the value to the variable. Any ideas how I can get the date number into a Month - Year string??

@barryrodick
can you try following:
grafik
ensure following imports:
grafik

JsonConvert.DeserializeObject(Of DateTime)("new Date(1594526400000)", new JavaScriptDateTimeConverter())

It seems the value is Unix timestamp.

Assign:

MyDate = DateTimeOffset.FromUnixTimeMilliseconds(<your_numeric_value_here>).DateTime

E.g:

MyDate = DateTimeOffset.FromUnixTimeMilliseconds(1612155600000).DateTime

Hi This seems to work when using the number directly, but it doesn’t seem to work if I replace the number with a variable.

DateTimeOffset.FromUnixTimeMilliseconds(item(“startDate”)).DateTime

Thanks for helping with this.

give a try on
DateTimeOffset.FromUnixTimeMilliseconds(item(“startDate”).Value(Of Long)).DateTime

Hi @barryrodick,

The parameter must be a numeric value, try to convert as @ppr said or:

DateTimeOffset.FromUnixTimeMilliseconds(Clng(item("startDate").ToString)).DateTime

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.