How to find out the next Friday using RelativeDateTime

V

vj

I'm doing:

a = now()
delta = ReltaiveDateTime(days=+6, weekday(mx.DateTime.Friday, 0))
Next Friday: a+delta

a: march 23
a+delta: Gives me March 31st and not March 24th

Any ideas?
 
D

Dennis Lee Bieber

I'm doing:

a = now()
delta = ReltaiveDateTime(days=+6, weekday(mx.DateTime.Friday, 0))
Next Friday: a+delta

a: march 23
a+delta: Gives me March 31st and not March 24th

Any ideas?

Off-hand? (Since I don't think I have that function)...

Don't add the 6... It would appear that you are jumping over the
24th, and then picking up the first Friday that follows the result of
jumping.
--
 
V

vj

I figured out how to do it. This does not work:

delta = ReltaiveDateTime(days=0, weekday(mx.DateTime.Friday, 0))

But this works:

delta = ReltaiveDateTime(days=+0, weekday(mx.DateTime.Friday, 0))
 
J

John Machin

Off-hand? (Since I don't think I have that function)...

Don't add the 6... It would appear that you are jumping over the
24th, and then picking up the first Friday that follows the result of
jumping.

Good call, Dennis.

vj: It would help for future questions if you were to copy and paste
code that you had actually run, rather than typing it from memory. There
are TWO typos in what your wrote. It would also help if you showed
exactly what import statement(s) were used, as in the following (where I
have substituted Saturday for Friday, in the interests of reproducing
your (volatile) test case).

Hope this helps,
John
 
V

vj

Thanks for pointing out that the days=+0 is not necessary. Your other
points are well noted.

Thanks

VJ
 
J

John Machin

I figured out how to do it. This does not work:

delta = ReltaiveDateTime(days=0, weekday(mx.DateTime.Friday, 0))

But this works:

delta = ReltaiveDateTime(days=+0, weekday(mx.DateTime.Friday, 0))

vj, NEITHER of those work, because you still have the two typos.
Secondly, there is absolutely no difference in Python between 0 and +0.
PLEASE post actual code (plus the results of running it), like this
(which continues from my previous posting):

Cheers,
John
 
F

fumanchu

a = now()
delta = ReltaiveDateTime(days=+6, weekday(mx.DateTime.Friday, 0))
Next Friday: a+delta
a: march 23
a+delta: Gives me March 31st and not March 24th
Any ideas?

Just an off-beat idea: use Python's datetime instead of mx.DateTime,
and my recur module:
http://projects.amor.org/misc/wiki/Recur
datetime.date(2006, 3, 24)


Robert Brewer
System Architect
Amor Ministries
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,291
Messages
2,571,453
Members
48,132
Latest member
AnneHarpur

Latest Threads

Top