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? 5 3685
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))
On 24/03/2006 5:18 AM, Dennis Lee Bieber wrote: On 23 Mar 2006 09:37:13 -0800, "vj" <vi******@gmail.com> declaimed the following in comp.lang.python:
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.
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). from mx.DateTime import * a = now() a
<DateTime object for '2006-03-24 06:13:46.89' at b00760> delta=RelativeDateTime(days=6, weekday=(Saturday, 0)) a + delta
<DateTime object for '2006-04-01 06:13:46.89' at ae6620> delta=RelativeDateTime(weekday=(Saturday, 0)) a + delta
<DateTime object for '2006-03-25 06:13:46.89' at b00aa0>
Hope this helps,
John
Thanks for pointing out that the days=+0 is not necessary. Your other
points are well noted.
Thanks
VJ
On 24/03/2006 6:30 AM, vj wrote: 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): delta2=RelativeDateTime(days=0, weekday=(Saturday, 0)) delta3=RelativeDateTime(days=+0, weekday=(Saturday, 0)) delta2
<RelativeDateTime instance for 'YYYY-MM-DD Sat:0 HH:MM:SS' at 0xae5f08> delta3
<RelativeDateTime instance for 'YYYY-MM-DD Sat:0 HH:MM:SS' at 0xb01468> a+delta2 == a+delta3
True a+delta == a+delta2 == a+delta3
True
Cheers,
John
> 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 import datetime, recur recur.Recurrence(datetime.date.today(), "Friday").next()
datetime.date(2006, 3, 24)
Robert Brewer
System Architect
Amor Ministries fu******@amor.org This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matt |
last post by:
My ASP page allows the user select the date, and it will display the report
during that week of that date.
My question is when the program query database, I need to know the beginning
date and...
|
by: Laguna |
last post by:
Hi Gurus,
I want to find the expiration date of stock options (3rd Friday of the
month) for an any give month and year. I have tried a few tricks with
the functions provided by the built-in...
|
by: Peter |
last post by:
Has anyone written any code to find the date of every other Friday of the year?
Is there an easy way of doing this?
|
by: CK |
last post by:
Hi All,
Looking for a simple function to return the date for the follwing Friday. I
send out emails from time to time and I would like a function that
dynamically returns the date for the...
|
by: thebjorn |
last post by:
For the purpose of finding someone's age I was looking for a way to
find how the difference in years between two dates, so I could do
something like:
age = (date.today() - born).year
but that...
|
by: ibiza |
last post by:
Hi all,
I need to find a specific, for example the third friday of a given
month/year. How to do that?
thanks :)
|
by: sherifffruitfly |
last post by:
Hi all,
This is how I'm currently getting Friday of last week. It strikes me as
cumbersome. Is there a slicker/more elegant way?
Thanks for any ideas,
cdj
|
by: =?Utf-8?B?UGF1bA==?= |
last post by:
HI I have a stored procedure that returns data with a date field in the form
of a DateTime type. I need to place data in variables based on days of the
week starting with the first thursday of the...
|
by: muddasirmunir |
last post by:
i am using vb6. what i need is to calculate X (means any ) working day
date skipping holidays (saturday and sunday) or (friday or saturday in some contries)
for example:
today is 20-06-2008...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |