[Adobe Analytics API] Specifying report date format. | Community
Skip to main content
New Participant
Nov 15, 2021 11:44 AM UTC
Solved

[Adobe Analytics API] Specifying report date format.

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
David_Jerome
David_JeromeAccepted solution
Level 6
Nov 15, 2021 12:40 PM UTC

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.

 

 

7 replies

Employee
Nov 15, 2021 11:59 AM UTC
New Participant
Nov 15, 2021 2:19 PM UTC

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

Translate
David_Jerome
Level 6
Nov 15, 2021 11:57 AM UTC

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'..............

Translate
New Participant
Nov 15, 2021 12:17 PM UTC

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", ...​
Translate
David_Jerome
David_JeromeAccepted solution
Level 6
Nov 15, 2021 12:40 PM UTC

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.

 

 

Translate