Hi-
I want to make a list of mx.DateTime objects that cover all the monthly
intervals between two points. For example: import mx.DateTime nov1999 = mx.DateTime.Date(1999, 11) mar2003 = mx.DateTime.Date(2003, 3) alldates = mk_list(startdate=nov1999, enddate=mar2003) alldates
[ ... a bunch of mx.DateTime objects including and between the startdate
and enddate ...]
How would I do something like this?
Thanks for the help. 3 2874
On Tue, 16 Sep 2003 16:02:53 -0400 (EDT), rumours say that py****@sarcastic-horse.com might have written: I want to make a list of mx.DateTime objects that cover all the monthly intervals between two points. For example:
import mx.DateTime nov1999 = mx.DateTime.Date(1999, 11) mar2003 = mx.DateTime.Date(2003, 3) alldates = mk_list(startdate=nov1999, enddate=mar2003) alldates
[ ... a bunch of mx.DateTime objects including and between the startdate and enddate ...]
How would I do something like this?
I'm not familiar with the exact names of the mx functions, but what I
would do, would be:
create an empty list
set an mx.DateTime object to the start date
while the mx.DateTime is less or equal to the end date:
append it to the list, add one day to it
Add some parentheses and you got the python code :)
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
Christos TZOTZIOY Georgiou wrote: On Tue, 16 Sep 2003 16:02:53 -0400 (EDT), rumours say that py****@sarcastic-horse.com might have written:
I want to make a list of mx.DateTime objects that cover all the monthly intervals between two points. For example:
>import mx.DateTime >nov1999 = mx.DateTime.Date(1999, 11) >mar2003 = mx.DateTime.Date(2003, 3) >alldates = mk_list(startdate=nov1999, enddate=mar2003) >alldates
[ ... a bunch of mx.DateTime objects including and between the startdate and enddate ...]
How would I do something like this?
I'm not familiar with the exact names of the mx functions, but what I would do, would be:
create an empty list set an mx.DateTime object to the start date while the mx.DateTime is less or equal to the end date: append it to the list, add one day to it
Add some parentheses and you got the python code :)
Not the fastest, but the easy to read:
from mx.DateTime import Date, RelativeDate
def daterange(startdate, enddate, delta=RelativeDate(months=+1)):
l = []
date = startdate
while date < enddate:
l.append(date)
date += delta
return l
--
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, Sep 16 2003) Python/Zope Products & Consulting ... http://www.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
__________________________________________________ ______________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
Christos TZOTZIOY Georgiou wrote: On Tue, 16 Sep 2003 16:02:53 -0400 (EDT), rumours say that py****@sarcastic-horse.com might have written:
I want to make a list of mx.DateTime objects that cover all the monthly intervals between two points. For example:
>import mx.DateTime >nov1999 = mx.DateTime.Date(1999, 11) >mar2003 = mx.DateTime.Date(2003, 3) >alldates = mk_list(startdate=nov1999, enddate=mar2003) >alldates
[ ... a bunch of mx.DateTime objects including and between the startdate and enddate ...]
How would I do something like this?
I'm not familiar with the exact names of the mx functions, but what I would do, would be:
create an empty list set an mx.DateTime object to the start date while the mx.DateTime is less or equal to the end date: append it to the list, add one day to it
Add some parentheses and you got the python code :)
Not the fastest, but the easy to read:
from mx.DateTime import Date, RelativeDate
def daterange(startdate, enddate, delta=RelativeDate(months=+1)):
l = []
date = startdate
while date < enddate:
l.append(date)
date += delta
return l
--
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, Sep 16 2003) Python/Zope Products & Consulting ... http://www.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
__________________________________________________ ______________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! :::: This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Hunter |
last post by:
>>> from datetime import date
>>> dt = date(1005,1,1)
>>> print dt.strftime('%Y')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: year=1005 is before 1900; the...
|
by: Douglas Buchanan |
last post by:
I am using the following code instead of a very lengthly select case
statement.
(I have a lot of lookup tables in a settings form that are selected
from a ListBox. The data adapters are given a...
|
by: Pet Matrix. |
last post by:
Hi,
I am having the schema and one element in that schema is ,
<xs:element name="EndT" type="TstampType" minOccurs="1" maxOccurs="1"/>
How do I represent the NULL value for the datatype dateTime...
|
by: Gidi |
last post by:
hello, i have a textbox that represnts a date and i want to pare it to a
DateTime, but sometimes this textBox can be empty string and i want to send
it to the DataBase as null or as empty Date, how...
|
by: Sean |
last post by:
I have been using List(of String) when I could easily be using a string array
instead.
Is it still considered best practice to use Generic list of string rather
then a string array?
Thanks
|
by: GG |
last post by:
I am trying to add a nullable datetime column to a datatable fails. I am
getting exception
DataSet does not support System.Nullable<>.
None of these works
dtSearchFromData.Columns.Add( new...
|
by: Rick |
last post by:
I have a large list of objects where each object has a unique
(non-overlapping) date range. The list is sorted chronologically. What is
the most efficient way to search this list for a single...
|
by: JB |
last post by:
I am trying to get a list of all the active computers running on my
domain.
I'm writing some remote management style software with WMI, which
works fine when i know the computer name, but i just...
|
by: Ken Foskey |
last post by:
I have a problem with the following if the EndDate on the database is
Null. Knowing this I can code around it but not knowing it was a very
frustrating experience!
...
|
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: 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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
|
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...
| |