Toggle navigation
Home
▼ Details
Products and pricing
Chart gallery
User stories
Text analytics
CDC NAMCS Library
Blog
Tutorials
Contact
Sign in
Post Editor
← All help posts
View post
Save
<img src="/uploads/upload/image/5200/direct/1561514247123-chart-cumulative-crosstab.png" alt="Cumulative distribution chart showing survey completion dates over time by country. Five colored lines (Overall, Germany, Spain, France, Italy) track the percentage of completed surveys from March 25 to April 15, 2018, with all reaching 100% by the end of the period." style="width: 360px;" class="fr-fic fr-dib"> 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: <img src="/uploads/upload/image/5200/direct/1561514278419-date-string-iso.png" alt="Spreadsheet view showing the lastcomplete column containing date-time values in ISO 8601 format. Sample values include "2018-04-08T16:09:28.903+00:00" and several other timestamps from April 2018." style="width: 240px;" class="fr-fic fr-dib"> 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: <img src="/uploads/upload/image/5200/direct/1561514302736-date-marginal-str.png" alt="Protobi frequency table showing lastcomplete variable treated as categorical string values. The table displays a long list of unique ISO 8601 date-time strings (like "2018-03-29T21:12:33.16+00:00") each with a frequency of 1, demonstrating the problem of treating dates as categorical text." style="width: 360px;" class="fr-fic fr-dib"> ## 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"`. <img src="/uploads/upload/image/5200/direct/1561514335915-date-properties.png" alt="Advanced properties dialog for the lastcomplete field with a dropdown menu showing type options. The "date" option is highlighted in the list which includes string, number, date, empty, and other data types." style="width: 240px;" class="fr-fic fr-dib"> Protobi now parses the date strings as date values. You can see that the data now shows the full ISO Date-Time value: <img src="/uploads/upload/image/5200/direct/1561514361208-date-marginal-iso.png" alt="Protobi frequency table showing lastcomplete variable after being parsed as date type. Date values now display in ISO format with timezone (like "2018-03-21T16:34:02.017Z") and each shows a frequency percentage of 0.3% with small bar indicators." style="width: 360px;" class="fr-fic fr-dib"> ### 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)](https://xkcd.com/1179/). ## 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": <img src="/uploads/upload/image/5200/direct/1561514391870-date-marginal-mmyyyy.png" alt="Protobi view showing a transformed date variable q14x2 displaying dates in MM/YYYY format (like "01/2018", "04/2018", "02/2018"). The frequency table shows various months from 2016-2018 with percentages ranging from 1.8% to 4.8%, plus [NA] at 37.2%." style="width: truepx;" class="fr-fic fr-dib"> Protobi already includes the leading date-time library [moment.js](https://momentjs.com/docs/#/parsing/) 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: <img src="/uploads/upload/image/5200/direct/1561514415603-chart-type-dialog.png" alt="Chart configuration dialog showing chart type and options. The "cumul" (cumulative) chart type is selected in the Chart type section, and "Cumulative distribution" is highlighted in the Chart options section. Legend position is set to "right"." style="width: 360px;" class="fr-fic fr-dib"> The chart now shows a cumulative distribution with the date values on the horizontal axis: <img src="/uploads/upload/image/5200/direct/1561514437873-chart-cumulative.png" alt="Cumulative distribution line chart for lastcomplete variable showing survey completion over time. A single blue line progresses from 0% on March 25, 2018 to 100% by April 15, 2018, with the steepest increase occurring around April 1." style="width: 360px;" class="fr-fic fr-dib"> ## 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 [](/intermediate-editor/transform)[transform dialog](/intermediate-editor/transform). <img src="/uploads/upload/image/5200/direct/1644326917728-1644326917728.png" alt="Transform group dialog showing date transformation options. The "Day" option is selected (filled radio button) among various choices including None, Sum, Mean, statistical functions, and date-specific transforms like Year, Quarter, Month, Day, Hour, Day name, and Day of week." style="width: 307px;" class="fr-fic fr-dib"> <img src="/uploads/upload/image/5200/direct/1561514459627-chart-cumulative-day.png" alt="Cumulative distribution line chart for lastcomplete with dates transformed to discrete days. The blue line shows survey completion from March 25 to April 15, 2018, with visible circular markers at each daily data point, making the discrete day grouping evident." style="width: 360px;" class="fr-fic fr-dib"> 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: <img src="/uploads/upload/image/5200/direct/1561514485169-marginal-dayofweek.png" alt="Protobi frequency table showing lastcomplete transformed to day of week. Seven rows display weekdays as "1-Mon" through "7-Sun" with frequencies ranging from 4.5% to 34.2%, plus a sample size N of 1203. Thursday (34.2%) has the highest completion rate." style="width: 360px;" class="fr-fic fr-dib"> Date and time charts can also be crosstabbed like other elements. For instance, completion date by country: <img src="/uploads/upload/image/5200/direct/1571146053917-1571146053917.png" alt="Crosstab table showing lastcomplete dates by Country. Rows display dates from 4/1/2018 to 4/18/2018 (8:00:00 PM), and columns show countries: Australia, Germany, Erie, Greenland, and Mexico. Cell values show the count of survey completions for each date-country combination." style="width: 600px;" class="fr-fic fr-dib"> Date and time values often arise in context of more advanced analytics goals, such as intervals, and regimens. See our [Date/time calculations](/intermediate-editor/date-time-calc) tutorial to learn more.
Publishing
Date
Status
Published
Draft
Slug
edit
Content
Thumbnail
Categories
Manage
New to Protobi?
Charts
Making Changes
Intermediate topics for editors
Frequently Asked Questions
SERMO Topics
Tutorial Pages
Internal Docs
Data Processing
Videos
Obsolete
GSG Admin
SERMO Admin
GSG Topics
How to...
Basics for viewers
Basics for editors
For project admins
Advanced topics
Assessments
Articles (in-progress)
New and updated articles
Process data in Protobi
superseded
Text open-end questions
Troubleshooting
Tracking studies
Organizing the view
API References
Tools
AI Database
Checking AI...
Convert to MD
Danger zone
Delete