Expand my Community achievements bar.

Join us January 15th for an AMA with Champion Achaia Walton, who will be talking about her article on Event-Based Reporting and Measuring Content Groups!
SOLVED

[Adobe Analytics API] Specifying report date format.

Avatar

Level 1

Hello,

Is it possible to specify the format of the date values in the JSON report built using the Adobe Analytics API?

For example, currently date comes in format Month Day, Year. Is it possible to get the date in an ISO 8601 format (Year-Month-Day)?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 8

Gotcha!

 

Just had a look back at my scripts (using Python) and I did a work around.

 

AdobeAPIdate = today - timedelta(days = 1)

#CREATE THE ADOBE API DATES WITH ADOBE NAMING LOGIC (E.G. 00 for Jan)
adjust = 1
while adjust < 31:
if ((str(AdobeAPIdate))[5:7]) == '01':
monthshift = '00'
elif ((str(AdobeAPIdate))[5:7]) == '02':
monthshift = '01'
elif ((str(AdobeAPIdate))[5:7]) == '03':
monthshift = '02'
elif ((str(AdobeAPIdate))[5:7]) == '04':
monthshift = '03'
elif ((str(AdobeAPIdate))[5:7]) == '05':
monthshift = '04'
elif ((str(AdobeAPIdate))[5:7]) == '06':
monthshift = '05'
elif ((str(AdobeAPIdate))[5:7]) == '07':
monthshift = '06'
elif ((str(AdobeAPIdate))[5:7]) == '08':
monthshift = '07'
elif ((str(AdobeAPIdate))[5:7]) == '09':
monthshift = '08'
elif ((str(AdobeAPIdate))[5:7]) == '10':
monthshift = '09'
elif ((str(AdobeAPIdate))[5:7]) == '11':
monthshift = '10'
elif ((str(AdobeAPIdate))[5:7]) == '12':
monthshift = '11'
AdobeCustomDates.append((str(1))+((str(AdobeAPIdate))[2:4])+monthshift+((str(AdobeAPIdate))[8:11]))
adjust += 1
AdobeAPIdate = today - timedelta(days = adjust)

 

Then I used "AdobeAPIdate" as the date for output to SQL / google sheets.

 

 

View solution in original post

7 Replies

Avatar

Level 8

Yes you can.

 

Here is bit of the code I use...

 


body = {
'rsid': 'yourrsid',
'globalFilters': [
{
'type': 'dateRange',
'dateRange': '2021-03-01T00:00:00.000/2021-03-05T00:00:00.000'
}
],
'metricContainer': {
'metrics': [
{
'columnId': 'metrics/event1:::0'..............

Avatar

Level 1

I meant on the resulting JSON report.
When using the dimension 'variables/daterangeday', the date values come in the format 'Month Day, Year', for example:

...
"value":"Dec 31, 2017",
...

What I'm looking for here would be so these dates come in ISO 8601 format:

...
"value":"2017-12-31",
...​

Avatar

Correct answer by
Level 8

Gotcha!

 

Just had a look back at my scripts (using Python) and I did a work around.

 

AdobeAPIdate = today - timedelta(days = 1)

#CREATE THE ADOBE API DATES WITH ADOBE NAMING LOGIC (E.G. 00 for Jan)
adjust = 1
while adjust < 31:
if ((str(AdobeAPIdate))[5:7]) == '01':
monthshift = '00'
elif ((str(AdobeAPIdate))[5:7]) == '02':
monthshift = '01'
elif ((str(AdobeAPIdate))[5:7]) == '03':
monthshift = '02'
elif ((str(AdobeAPIdate))[5:7]) == '04':
monthshift = '03'
elif ((str(AdobeAPIdate))[5:7]) == '05':
monthshift = '04'
elif ((str(AdobeAPIdate))[5:7]) == '06':
monthshift = '05'
elif ((str(AdobeAPIdate))[5:7]) == '07':
monthshift = '06'
elif ((str(AdobeAPIdate))[5:7]) == '08':
monthshift = '07'
elif ((str(AdobeAPIdate))[5:7]) == '09':
monthshift = '08'
elif ((str(AdobeAPIdate))[5:7]) == '10':
monthshift = '09'
elif ((str(AdobeAPIdate))[5:7]) == '11':
monthshift = '10'
elif ((str(AdobeAPIdate))[5:7]) == '12':
monthshift = '11'
AdobeCustomDates.append((str(1))+((str(AdobeAPIdate))[2:4])+monthshift+((str(AdobeAPIdate))[8:11]))
adjust += 1
AdobeAPIdate = today - timedelta(days = adjust)

 

Then I used "AdobeAPIdate" as the date for output to SQL / google sheets.

 

 

Avatar

Level 1

Thanks for your example. I also have a way to post-process the date format in the report to the one I want but I was just wondering if there's a way to obtain the intended format directly in the report (through some POST request parameter) without having to apply any transformations.

Avatar

Level 8

Sadly I don't think so.

Do let me know if you find out a way.

Avatar

Level 1

Is there a section that references defining the date format in the report? Please see my reply above for an example.