Date/time values

Updated at February 8th, 2022

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 into different values

You can transform dates to a specific value. For example, the lastcomplete variable records date and time. But we can cluster the values into discrete days, and ignore the time values using the transform dialog.

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 transform options include values by the day of week or month. When transformed, the values are still dates, but rounded to the nearest value. They still retain their broader context like year, so "Feb 17, 2017" and "Feb 17, 2018" are recognized as different days. 

Values 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?