Date/time values

Updated at July 29th, 2020

Your survey data might have one or more columns with date values. There are various ways you can parse and analyze dates in Protobi.

For instance, most surveys have an interview completion date:

Unless your data file identifies the column as date values, Protobi interprets date strings like any other string, and shows a distribution of the string values, treating each string as a categorical value:

Parse dates

You can identify an element as date values by selecting "More properties..." from the edit icon and setting type to "date." You can also do this in the "Edit JSON..." dialog by setting "type": "date".

Protobi now parses the date strings as date values. You can see that the data now shows the full ISO Date-Time value: 

ISO date format

Here, Protobi was able to easily interpret the strings because they came in a standard date time format that is recognized by all browsers. This particular format, YYYY-MM-DD is the ISO 8601 format. It might look unusual but this is the international standard date formats, as noted in this XKCD Cartoon (other formats exist like RFC 2822).

Custom date formats

It's possible your dates come in a different, reasonable but non-standard format. Below we see dates in the format "MM/YYYY":

Protobi already includes the leading date-time library moment.js that can parse a very wide variety of dates. To specify a specific format, select "Edit JSON..." from the edit icon and in the editor add the attribute "dateFormat": "MM/YYYY"

Cumulative charts

Protobi charts recognize date values. For instance set the chart type to cumulative:

The chart now shows a cumulative distribution with the date values on the horizontal axis:

Transform dates

You can transform dates as well. Here, survey respondents completed surveys throughout the day. We can cluster the date values into discrete days by setting "transform":"day":

Here, we also added markers by using the Plotly option, "chartOptions.mode": "lines+markers" to make it easy to see that values are grouped into discrete days.

Other options are "year", "month", "day", "hour", "minute", "second". These are still date values, while rounded to the nearest value, they still retain their broader context like year, so "Feb 17, 2017" and "Feb 17, 2018" are different days.

Alternately, we can combine values by day name or month name, by setting "transform" to "dayofweek" or "monthofyear". These include the integer index so that they sort correctly:

Date and time charts can also be crosstabbed like other elements. For instance, completion date by country:

Date and time values often arise in context of more advanced analytics goals, such as intervals, and regimens. See our Date/time calculations tutorial to learn more. 

Was this article helpful?