Skip to content

Date Operations #10297

Closed
Closed
@ywhcuhk

Description

@ywhcuhk

IMHO, two date functions from SAS can be very useful and straight forward. I wonder if they can be incorporated in Pandas.

intck()

This function computes the difference between 2 dates/datetime with specified units. For example
Assume: d1=1992-03-20 and d2=1992-06-12. And these are all of date type in SAS.
intck('month', d1, d2) yields 3 (regardless of what day it is). intck('qtr', d1, d2) yields 1. intck('year', d1, d2) yields 0.

intnx()

This function increments a given date by an interval. Assuming d1=1992-03-20, intnx('month', d1, 3, 'end') yields 1992-06-30 (increase month by 3 and return the last day of that month. intnx('month', d1, 3, 'same') yields 1992-06-20 (increase month by 3 and return the same day of that month.


As you can see, these two functions are very flexible and simple. The whole offset system seems to be a little too cumbersome comparing to these 2.


See this question too. Especially the solution offered by @hayd

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions