Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-36680

Ability to format string values as dates while reading from Couchbase

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 7.1.0
    • 6.0.3
    • query
    • Medium

    Description

      Requirement is as follows:

      {
        "patientBirthDate": "19/08/2011 6:33:23"
      }
      

      We are trying to correct the date format to a standardised date format i.e. 2011-08-19 using an update query. Our initial idea was to use a query like below:

      UPDATE patients SET patientBirthDate = DATE_FORMAT_STR(DATE_PARSE(patientBirthDate, 'dd/MM/yyyy h:mm:ss'), '1111-11-11') WHERE ....
      

      But to our surprise there was not inbuilt SQL function (e.g. DATE_PARSE) to parse a string into date using a format specifier. So had to resort to a string split and concat query for now.

      UPDATE patients SET patientbirthDate = concat(split(split(patientbirthDate)[0], "/")[2], '-', split(split(patientbirthDate)[0], "/")[0] , 
      '-', split(split(patientbirthDate)[0], "/")[1])
      WHERE ...
      

      We feel this is a standard use case for any SQL engine.

      Please let me know if there is such a function which we may have missed.

      Attachments

        Issue Links

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

          Activity

            People

              mihir.kamdar Mihir Kamdar (Inactive)
              ramsankar Ramasubramanian Sankar
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty