Date Comparison and Manipulation Functions?

John Machin sjmachin at
Sat Aug 30 04:20:23 CEST 2008

On Aug 30, 10:41 am, "W. eWatson" <notval... at> wrote:

> What I'm trying to do is adjust date-time stamped file names for date and
> time errors. The software program collects through a period that roughly
> coincides with night hours every day and according to the OS clock. It
> sometimes happens that a user sets the clock to the wrong day or hour,
> possibly both. Possibly even the month or year. I'm trying to allow a user
> the opportunity to repair the problem. (Date-time stamp part of the name is
> yyyymmdd_hhmmss.) Correcting the date needs to be done easily and
> accurately. For example, if on August 25, he mistakenly sets the date to
> July 25, and discovers this problem on the real Oct. 5, he should be able to
> shift all dates from July 25 through Sept. 5 to Aug. 25 through early Oct.,
> allowing for day oddities in a month during the period. (I hope I got those
> dates right; otherwise, I think you get the idea. In other words, he needs
> to shift about 40 days of data to the correct dates.)

... all of which is absolutely nothing to do with your surprise at the
result of

So for some period from recorded date X to recorded date Y, the
recorded dates of out of kilter by D days. X = Jul 25 2008, Y Sep 5
2008, and D is 31 (days from Jul 25 to Aug 25). All you have to do is

if X <= recorded_date <= Y:
    new_recorded_date  =


More information about the Python-list mailing list