Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-11759

[C++] Kernel to extract datetime components (year, month, day, etc) from timestamp type

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 5.0.0
    • C++

    Description

      It can be very useful to extract certain "fields" from the timestamp, such as the year, month, day, etc.

      See eg https://pandas.pydata.org/docs/user_guide/timeseries.html#time-date-components for the ones available in pandas.

      Using pandas as an example, there are the basic components of the datetime:

      >>> ts = pd.Timestamp.now()
      >>> ts
      Timestamp('2021-02-24 10:47:54.294504')
      
      >>> ts.year
      2021
      >>> ts.month
      2
      >>> ts.day
      24
      >>> ts.hour
      10
      >>> ts.minute
      49
      >>> ts.second
      54
      >>> ts.microsecond
      607393
      >>> ts.nanosecond
      0
      

      (only for the sub-second, this is not fully clear how to divide it in microseconds or milliseconds, etc)

      But in addition also some more "advanced" like:

      >>> ts.dayofyear
      55
      >>> ts.dayofweek
      2
      >>> ts.week
      8
      >>> ts.isocalendar()
      (2021, 8, 3)
      

      Attachments

        Issue Links

          Activity

            People

              rokm Rok Mihevc
              jorisvandenbossche Joris Van den Bossche
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 18h 40m
                  18h 40m