Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-3942

Add UDF month_add and month_sub

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • 0.9.0
    • None
    • UDF
    • None

    Description

      hive (default)> desc function extended month_add;
      month_add(start_date, num_months) - Returns the date that is num_months after start_date.
      Synonyms: month_sub
      start_date is a string in the format 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'. num_months is a number. The time part of start_date is ignored.
      Example:
      SELECT month_add('2012-04-12', 1) FROM src LIMIT 1; --Return 2012-05-12
      SELECT month_add('2012-04-12 11:22:31', 1) FROM src LIMIT 1; --Return 2012-05-12
      SELECT month_add(cast('2012-04-12 11:22:31' as timestamp), 1) FROM src LIMIT 1; --Return 2012-05-12

      hive (default)> desc function extended month_sub;

      month_sub(start_date, num_months) - Returns the date that is num_months after start_date.
      Synonyms: month_add
      start_date is a string in the format 'yyyy-MM-dd HH:mm:ss' or 'yyyy-MM-dd'. num_months is a number. The time part of start_date is ignored.
      Example:
      SELECT month_sub('2012-04-12', 1) FROM src LIMIT 1; --Return 2012-05-12
      SELECT month_sub('2012-04-12 11:22:31', 1) FROM src LIMIT 1; --Return 2012-05-12
      SELECT month_sub(cast('2012-04-12 11:22:31' as timestamp), 1) FROM src LIMIT 1; --Return 2012-05-12

      Attachments

        1. HIVE-3942-1.patch
          7 kB
          caofangkun

        Issue Links

          Activity

            People

              Unassigned Unassigned
              caofangkun caofangkun
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: