I'm doing:
a = now()
delta = ReltaiveDateTim e(days=+6, weekday(mx.Date Time.Friday, 0))
Next Friday: a+delta
a: march 23
a+delta: Gives me March 31st and not March 24th
Any ideas? 5 3710
I figured out how to do it. This does not work:
delta = ReltaiveDateTim e(days=0, weekday(mx.Date Time.Friday, 0))
But this works:
delta = ReltaiveDateTim e(days=+0, weekday(mx.Date Time.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.pytho n:
I'm doing:
a = now() delta = ReltaiveDateTim e(days=+6, weekday(mx.Date Time.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=RelativeD ateTime(days=6, weekday=(Saturd ay, 0)) a + delta
<DateTime object for '2006-04-01 06:13:46.89' at ae6620> delta=RelativeD ateTime(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 = ReltaiveDateTim e(days=0, weekday(mx.Date Time.Friday, 0))
But this works:
delta = ReltaiveDateTim e(days=+0, weekday(mx.Date Time.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=Relative DateTime(days=0 , weekday=(Saturd ay, 0)) delta3=Relative DateTime(days=+ 0, weekday=(Saturd ay, 0)) delta2
<RelativeDateTi me instance for 'YYYY-MM-DD Sat:0 HH:MM:SS' at 0xae5f08> delta3
<RelativeDateTi me 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 = ReltaiveDateTim e(days=+6, weekday(mx.Date Time.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.Recurrenc e(datetime.date .today(), "Friday").next( )
datetime.date(2 006, 3, 24)
Robert Brewer
System Architect
Amor Ministries fu******@amor.o rg 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 ending date of that week.
Any ideas??
|
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 module time, but the problem was
that the 9 element tuple need to be populated correctly. Can anyone
help me out on this one?
Thanks a bunch,
Laguna
|
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 follwing Friday. So no matter what day
I send it, it will dynamically calculate Friday's date. Also if I am sending
it on a Friday, I would like to return the current date, Saturday and later
will return next Friday's date. Thanks for any advice.
...
|
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 didn't work (the timedelta class doesn't have a year
accessor).
I looked in the docs and the cookbook, but I couldn't find anything, so
| |
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 month. So the week would be
week 1= (first thursday of the month through the next wed). So for example
for July 07 the first thursday is july5th so the first week would be thursday
july 5th , friday july 6th, sat july 7th, sun july 8th, mon...
|
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 and its friday (the holidays will be saturday and sunday)
now if i say 2 working days
so it should give me anwer 24-06-2008
that is adding 4 days to 20-06-2008 (2 holidays and 2 working days)
so how to achive this task
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |