{
  "id": "1996-march-how-to-get-a-date",
  "slug": "1996-march-how-to-get-a-date",
  "url": "https://dwillis.github.io/uplink/article/1996-march-how-to-get-a-date.html",
  "year": 1996,
  "month": "March",
  "monthNum": 3,
  "headline": "How to get a date",
  "kicker": "Tech tips",
  "author_name": "Andrew Lehren",
  "author_title": "NICAR Staff",
  "affiliation": "NICAR",
  "summary": "This article teaches journalists how to convert improperly formatted date data in FoxPro databases into proper date columns that enable calendar calculations and date-based queries without complex workarounds.",
  "keywords": [
    "database",
    "dates",
    "FoxPro"
  ],
  "topics": [
    "Data & Databases",
    "Investigative Methods",
    "Technology"
  ],
  "technologies": [
    "FoxPro"
  ],
  "full_text": "This is for those whose lives have gotten to the point where they want to get a date out of a database.\n\nA lot of databases include information that looks like a date, but instead is a character. Variations on this theme include separate columns for the month, day and year. Or single fields with 19940131. Or 103195. Or 9931231.\n\nBut database managers don't know these are dates unless we help them. Here is how to help FoxPro without writing contorted queries every time. Once this is done, reporters can run calculations using FoxPro's calendar brain.\n\nMake a date column\n\nThe first step is to create a new column in your table. Go to Database on the menu bar. Pick Setup Then Modify Insert a new column where you want it. Under Name, let's call it Newdate. And, under Type, choose Date. FoxPro automatically picks the width. Click OK. Then agree to make the changes permanent. Close out of the Setup box. Congratulations, you've created the target date column, filled with blank spaces and / marks, waiting to be filled with things like 11/12/94 and 01/10/60.\n\nFill the dates\n\nNow, we will fill Newdate with what we want. For the sake of unoriginality, let's call the oldcolumn with the faux character dates Olddate. Get the command window, and get ready to write. The first step is REPLACE ALL NEWDATE WITH. This is pretty clear. We are getting ready to put stuff into Newdate.\n\nThe next phrase is CTOD( This is FoxPro's function for changing characters to dates. The parenthesis is open at this point because there is more to come. We will close it at the end. For the sake of clarity, add and go the next line, where we will stuff the CTOD() function.\n\nThis part depends on how the Olddate character dates appear. We are about to pull out the month, then the day, then the year. That's how dates appear among the slashes for Americans. This trips up European journalists who are used to the day/month/year syntax.\n\nLet's say Olddate contains 9931023 and 9960914 and such. The month is in the middle, starting in the fourth spot, and filling two places.\n\nFor this, we will use the SUBSTR() function. To pluck them out, type this: SUBSTR(Olddate,4.,2 Now, for the first slash, type + \"/\" + For the day, beginning in the sixth spot, we will use the same function: SUBSTR(Olddate,6,2) Add another slash with \"/\" + And finish with the year, which starts on the second space: SUBSTR(Olddate,2,2). To keep things clear, don't forget you can break the line at any time with Don't forget to close all this with a).\n\nRemember: The first digit indicates the starting position of the substring of numbers you want to pluck out, and the second digit indicates how many places you want to pluck out.\n\nPut this all together and you get:\nReplace all Olddate with ctod(\nsubstr(Olddate,4,2) +\"/\"+;\nsubstr(Olddate,6,2) substr(Olddate,2,2);\n)\n\nHit enter, and FoxPro will do all the work. There are variations. For the three separate month, day, year columns, you would supplant the middle three lines of this command with:\noldmonth + oldday + \"/\" oldyear\nIf you face a year in the first two spaces, you could save a couple key strokes with the LEFT() function, which knows to start pulling things from the left. You just have to tell it how far. For 071496, use this for the middle three lines:\nleft(Olddate,2) + \"/\" +:\nsubstr(Olddate,4,2) + \"p\" ;\nsubstr(Olddate,6,2)\nYou may also see another variation in your data travels, where you get the month and the year in separate columns, but not the day. You can still coax FoxPro to help with calendar calculations. Just punch in a fake date, like 01 or 15. As with so many data problems, there are several solutions. Just remember that, in this case, you really don't know the day. The middle three lines in this example are:\noldmonth + \"/\" \"15\"+\"\";\noldyear ;\nNow, you're set to start getting dates out of FoxPro. Andrew Lehren can be reached at (573) 882-0684, or send e-mail to andy@nicar.org",
  "provenance": {
    "extracted_by": "anthropic/claude-sonnet-4-6",
    "extracted_at": "2026-07-05",
    "verified": true
  },
  "similar": [
    {
      "slug": "2000-april-text-to-date",
      "score": 0.439
    },
    {
      "slug": "1999-januaryfebruary-cant-get-a-date",
      "score": 0.436
    },
    {
      "slug": "1998-february-converting-dates-in-access",
      "score": 0.367
    },
    {
      "slug": "1998-july-tech-tip-tell-me-y2k-you-cry",
      "score": 0.286
    },
    {
      "slug": "1998-june-date-handling-in-popular-car-applications",
      "score": 0.257
    }
  ],
  "html_url": "https://dwillis.github.io/uplink/article/1996-march-how-to-get-a-date.html",
  "json_url": "https://dwillis.github.io/uplink/article/1996-march-how-to-get-a-date.json"
}