How do you describe a year (YYYY) in a JSON Table Schema?


#1

Is this the correct way to describe a 4 character year field in a JSON Table Schema?

        {
        "name": "year",
        "description": "Year data was collected in e.g. 2016",
        "type": "date",
        "format": "fmt: %Y",
        "constraints": {
          "required": true
        }

#2

Yes, this is the correct way to specify a 4 character year field in a JSON Table Schema.

The use of the fmt: prefix here is currently under discussion for removal. Here is the issue: https://github.com/frictionlessdata/specs/issues/260

edit: maybe remove the space between the %Y and the fmt:


#3

Thanks @danfowler. It’s confusing as when I use CSVLint to validate the data, this works:

         {
        "name": "year",
        "description": "Year data was collected in e.g. 2016",
        "constraints": {
          "required": true,
          "type": "http://www.w3.org/2001/XMLSchema#gYear"
        }

Looks like CSVLint and GoodTables are not 100% aligned.


#4

GoodTables says, “No” using…

    {
  "name": "YEARS",
  "description": "Year data was collected in e.g. 2016",
  "type": "date",
  "format": "fmt: %Y",
  "constraints": {
    "required": true
  } 

Using this data uploaded from local file (issues when accessing via URL).

Any clues?


#5

Can you try removing the space between the fmt: and the %Y?

  "fields": [
    {
      "name": "YEARS",
      "description": "Year data was collected in e.g. 2016",
      "type": "date",
      "format": "fmt:%Y",
      "constraints": {
        "required": true
      }
    }
  ]