{
  "id": "1996-october-how-long-did-that-take",
  "slug": "1996-october-how-long-did-that-take",
  "url": "https://dwillis.github.io/uplink/article/1996-october-how-long-did-that-take.html",
  "year": 1996,
  "month": "October",
  "monthNum": 10,
  "headline": "How long did that take?",
  "kicker": "Tech Tip",
  "author_name": "Richard Mullins",
  "author_title": "",
  "affiliation": "University of Missouri/NICAR",
  "summary": "This article explains how to use custom FoxPro functions (DateTime, DateTimeDiff, and Hours) to calculate elapsed time between two date-time combinations, which is useful for analyzing database records like court cases, inspections, and emergency response times.",
  "keywords": [
    "database",
    "calculations",
    "FoxPro"
  ],
  "topics": [
    "Data & Databases",
    "Investigative Methods",
    "Technology"
  ],
  "technologies": [
    "FoxPro"
  ],
  "full_text": "Many databases include dates that define significant periods of time and deserve analysis. Court data can have arrest date, trial date and sentence date, for example. Inspection data can have date reported, date inspected and date enforcement action was taken.\n\nDatabase software has the capability to do calendar arithmetic to answer questions such as, \"Which case went the longest between arrest and trial?\" or \"Which inspection cases took the longest to get around to?\"\n\nSometimes, however, hours and minutes count. For example, you might want to calculate response times for emergency calls, phone call duration, or how long someone was in jail. Comparing the elapsed time with this information is a little more involved, since the beginning time may start at 2:03 p.m. on one day and the ending time may be at 5 a.m. the next morning or the next week.\n\nThis month's tip is a custom FoxPro function that you can use to do these time calculations. You can download the file TimeDat.zip from http://www.reporter.org\n\nThe file contains the source code for the functions, a sample table to test with, instructions on how to use the file and the functions.\n\nThe functions are: DateTime(), DateTimeDiff(), and Hours(). You can use these functions as you would the regular built-in FoxPro functions: in a query, or in a FoxPro command such as REPLACE ALL. Copy the file TimeDat.prg to your FoxPro directory and then in the command window, type:\n\nset procedure to TimeDat.prg\n\nThis makes the functions available. If you exit FoxPro or issue the CLOSE ALL command, you will have to type the command again to use the functions. For more information, see the documentation file included in TimeDat.zip\n\nFor illustration, I'll assume a table called TEST (included in TimeDat.zip) with five columns: ID, BeginDate, BeginTime, EndDate and EndTime. The question we're trying to answer is how much time passed between one starting date and time and the ending date and time.\n\nThe function DateTime takes two arguments: a date and a clock time. The clock time must be in the 24-hour format and indicated in hh:mm:ss or in hh:mm. The function converts the date and clock time to a single unit to define a point in time: the Julian day and the decimal proportion of the time of that day. If you want to think of Julian date as \"star date,\" that's OK, since it is used in astronomy to sidestep the quirks of our calendar.\n\nThe function DateTimeDiff compares two DateTime results and returns the time interval, expressed in days. To convert the interval to hours, divide the result by 24.\n\nHere are some query examples. This one uses DateTime:\nSELECT id, ;\nDateTime (begindate, begintime) ;\nDateTime (enddate, endtime) ;\nFROM test\n\nThis next query adds one more output column, using to calculate the days elapsed between beginning time/date and the ending time/date. Note that the functions are nested: the values returned from DateTime are passed to DateTimeDiff:\n\nSELECT id, ;\nDateTime (begindate, begintime) ;\nDateTime (enddate, endtime) ;\nDateTimeDiff (DateTime (begindate, begintime) ;\nDateTime (enddate, endtime) ) ;\nFROM test\n\nHere is how the DateTime function works, applying it to June 16, 1996, at 15:46:31.\n\nThe Julian date for 06/16/96 is 2450251. A Julian date is just a really big number: 2,450,251. It doesn't break down into anything else. At 15:46:31 on the clock, the day is 15.7753 hours old. Dividing that by 24 shows what proportion of the day has passed: 0.6573. Adding the Julian day and the proportion of the incomplete day gives the absolute reference we need to measure time periods that span a calendar day. With this kind of measure we can do time/date arithmetic on the mayor's cell phone calls. Here is what the FoxPro command window would look like to get these answers. The SYS(11) function is a built-in FoxPro function that converts a calendar date to a Julian date. FoxPro has more than 50 different SYS() functions (In the commands below, the lines in bold would show up on the screen, not in the command window).\n\nRichard Mullins can be reached at (573) 882-2127, or send e-mail to richard@nicar.org",
  "provenance": {
    "extracted_by": "anthropic/claude-sonnet-4-6",
    "extracted_at": "2026-07-05",
    "verified": true
  },
  "similar": [
    {
      "slug": "1998-june-a-more-perfect-union",
      "score": 0.288
    },
    {
      "slug": "1996-march-how-to-get-a-date",
      "score": 0.256
    },
    {
      "slug": "1997-september-setting-the-data-free",
      "score": 0.214
    },
    {
      "slug": "1997-june-whats-your-function",
      "score": 0.213
    },
    {
      "slug": "1997-march-tech-tip",
      "score": 0.206
    }
  ],
  "html_url": "https://dwillis.github.io/uplink/article/1996-october-how-long-did-that-take.html",
  "json_url": "https://dwillis.github.io/uplink/article/1996-october-how-long-did-that-take.json"
}