Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-8704

Support additional date format specifications [MB-47082]

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Minor
    • 7.2.0
    • None
    • query
    • None
    • DOC-2022-S9, DOC-2022-S10, DOC-2022-S11
    • 1

    Description

      The following documentation changes will be needed for Neo thanks to MB-47082 (wording of course can be finessed to suit overall style) :

      https://docs.couchbase.com/server/7.0/n1ql/n1ql-language-reference/datefun.html

      Section Date String Formats, change:

      All date formats follow the ISO-8601 standard.

      To:

      All default date formats follow the ISO-8601 standard.

      In table 2, add a line below the "Millisecond (of the second)" line:

      Nanosecond (of the second) sss 567123456
      (output only)

      Below table 3, the note changes:

      <was>

      Currently N1QL only accepts numeric format strings with valid values for each component. For example, you should pass something like "1111-11-11" as the date format rather than "YYYY-MM-DD", this has the same effect as passing in any other valid date in the same format (such as "2017-01-31").

      If the date string does not explicitly declare the value of a component, then a value of 0 is assumed. For example 2016-02-07 is equivalent to 2016-02-07T00:00:00. This is with the exception of the time zone, which if unspecified in the date string will default to the local system time zone.

      N1QL is very specific as to what it accepts as a valid date format, below are a few examples:

      "01:01:01" - Valid

      "hh:mm:ss" - Invalid

      "01:01:01.111" - Valid

      "01:01.111" - Invalid

      "2017-01-31" - Valid

      "2017-01-86" - Invalid

      <change to>

      N1QL accepts format strings following several conventions: example ISO-8601 format dates (e.g. "1111-11-11"), Go-lang native (e.g. specifically "2006-01-02" for year month & day), precent style (e.g. "%Y-%m-%d") or common components as noted in the code column of table 2 above (e.g. "YYYY-MM-DD"). Only a single style can be used at a time in a specified format string.

      If the date string does not explicitly declare the value of a component, then a value of 0 is assumed for numeric elements except month and day (which default to 1), century (when not specified with year which defaults to 19 if year is greater than or equal to 69 or 20 otherwise) and the local system time zone for time zone. For example 2016-02-07 is equivalent to 2016-02-07T00:00:00 and parsing just "16" as the year is equivalent to "2016-01-01T00:00:00" in the local system time zone.

      Characters not part of the format specification for percent style or common format strings are matched literally or produced unaltered with the exception of space (ASCII 32) which matches any single character when parsing (literal on output). e.g. "YYYY MM DD" or "%Y %m %d" will parse "2021-06-28", "2021/06/28", "2021.06.28" etc.

      Add a section "Percent-style date format options" with the content:

      Optionally Couchbase accepts a printf-style format specifier for dates based on the Unix date command. Format specifiers take the form:

      %% (a single literal percent sign)
      or
      %[-_0^][<width>][<element>]

      Minus , underscore (_) and zero indicate no padding, space padded and zero padded (default) number fields, circumflex (^) indicates case insensitivity when parsing text fields and a preference for upper case output of the fields. The width is accepted but ignored for parsing and is used for output but should rarely be needed as elements have common/expected default widths.

      Elements:

      D - short form date, YYYY-MM-DD e.g. 2021-06-28
      F - long form date, YYYY-MM-DDThh:mm:ss.sTZD, e.g. 2021-06-28T19:22:59.123+01:00
      Y - 4-digit century & year
      C - 2-digit century
      y - 2-digit year (default century when not specified is 19 if year is 69 or greater or 20 if less)
      m - 2-digit month
      B - full English month name, e.g. January
      b - abbreviated English month name, e.g. Jan
      d - 2-digit day
      e - space-padded 2-digit day (same as %_d)
      A - full English day name, e.g. Monday
      a - abbreviated English month name, e.g. Mon
      f - English number suffix, e.g. "st" (in "1st")
      H - 2-digit hour, 00...23
      I - 2-digit hour, 01...12
      k - space-padded 2-digit hour, 0...23 (same as %_H)
      l - space-padded 2-digit hour, 1...12 (same as %_I)
      p - AM or PM (upper case)
      P - am or pm (lower case)
      M - 2-digit minute, 00...59
      S - 2-digit second, 00...59
      R - 24-hour hour and minute (same as %H:%M)
      T - 24-hour time (same as %H:%M:%S)
      N - fraction of a second (down to nanosecond)
      z - time zone in any supported format when parsing (+hh, +hhmm, +hh:mm, zone-name) and +hh:mm format for output
      Z - same as z for parsing, zone name for output
      s - seconds since 1970-01-01 00:00:00 UTC

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              simon.dew Simon Dew
              Donald.haggart Donald Haggart
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty