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.Dat e(1999, 11) mar2003 = mx.DateTime.Dat e(2003, 3) alldates = mk_list(startda te=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 2892
On Tue, 16 Sep 2003 16:02:53 -0400 (EDT), rumours say that py****@sarcasti c-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.Dat e(1999, 11) mar2003 = mx.DateTime.Dat e(2003, 3) alldates = mk_list(startda te=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****@sarcasti c-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.Dat e(1999, 11) >mar2003 = mx.DateTime.Dat e(2003, 3) >alldates = mk_list(startda te=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(start date, enddate, delta=RelativeD ate(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,S olaris,FreeBSD for free ! ::::
Christos TZOTZIOY Georgiou wrote: On Tue, 16 Sep 2003 16:02:53 -0400 (EDT), rumours say that py****@sarcasti c-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.Dat e(1999, 11) >mar2003 = mx.DateTime.Dat e(2003, 3) >alldates = mk_list(startda te=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(start date, enddate, delta=RelativeD ate(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,S olaris,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 datetime strftime() methods require year >= 1900
Does anyone know of a datetime string formatter that can handles
strftime format strings over the full range that datetime objects
support?
|
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 similar name to the
table. Rather than making a long Select Case that could become
obsolete if lookup tables are added and the source table of the
ListBox is edited I came up with this code.)
This code works but of course it gives me build...
|
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 in the xml.
|
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 can i do it?
thanks
|
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 DataColumn( "StartDate",
typeof( DateTime? ) ) );
dtSearchFromData.Columns.Add( new DataColumn( "EndDate",
typeof( System.Nullable<DateTime>) ) );
Any ideas?
|
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 object that spans a
specified date?
|
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 want to be able
to produce a list and work it from there.
I found the following method:
String path = "WinNT://MY.DOMAIN.COM";
String username = "administrator";
|
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!
endDateTimePicker.DataBindings.Add(new Binding("Value",
MyDB.GameBindingSource, "EndDate"));
when I move position onto a record with a null enddate the BindingSource
it moves back again.
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |