Hello everyone,
please, I need your help. I'm new to python, so I don't know if this
will seem like a stupid question to some of you ...
I have a need to write to a file (or just print on screen, that part
doesn't matter at this point) a list of dates, starting today. For
example:
02.09.2008. tue
03.09.2008. wed
et cetera
Is there some intristic function in python which can help me with this
or do I have to do the calendar calculation by hand ?
Would appreciate all the help I can get.
Regards
Luka Djigas 2 2254
Luka Djigas wrote:
please, I need your help. I'm new to python, so I don't know if this
will seem like a stupid question to some of you ...
I have a need to write to a file (or just print on screen, that part
doesn't matter at this point) a list of dates, starting today. For
example:
02.09.2008. tue
03.09.2008. wed
et cetera
Is there some intristic function in python which can help me with this
or do I have to do the calendar calculation by hand ?
>>import datetime # see: http://docs.python.org/lib/module-datetime.html d = datetime.date.t oday() str(d)
'2008-09-01'
>>d.strftime("% d.%m.%Y. %a")
'01.09.2008. Mon'
>># see http://docs.python.org/lib/module-time.html#l2h-2826 d.strftime("% d.%m.%Y. %a").lower()
'01.09.2008. mon'
>>for i in range(10):
.... print d.strftime("%d. %m.%Y. %a").lower()
.... d += datetime.timede lta(days=1)
....
01.09.2008. mon
02.09.2008. tue
03.09.2008. wed
04.09.2008. thu
05.09.2008. fri
06.09.2008. sat
07.09.2008. sun
08.09.2008. mon
09.09.2008. tue
10.09.2008. wed
</F>
On 2008-09-01, Luka Djigas <ldigas@remove_ this.gmail.comw rote:
please, I need your help. I'm new to python, so I don't know if this
will seem like a stupid question to some of you ...
There are several ways to do it. Have a look at the documentation
of modules time and datetime. For this exact problem time is the
most straighforward one.
I have a need to write to a file (or just print on screen, that part
doesn't matter at this point) a list of dates, starting today. For
example:
02.09.2008. tue
03.09.2008. wed
0 hauva@laphroaig :~
$ /usr/bin/python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>import time DAY = 60 * 60 * 24 today = time.time() for i in (0, 1, 2, 3):
.... t = time.gmtime(tim e.time() + i * DAY)
.... print time.strftime(' %d.%m.%Y, %a', t)
....
01.09.2008, Mon
02.09.2008, Tue
03.09.2008, Wed
04.09.2008, Thu
--
Ari Makela late autumn - ha***@arska.org a single chair waiting http://arska.org/hauva/ for someone yet to come
-- Arima Akito This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Smoke |
last post by:
I have a successful script for determining today's date.
Does anyone have anything for determining tomorrow and the next day since it
would have to look at the day of month and month of year?
Thanks in advance.
|
by: Cillies |
last post by:
Does anyknow how to control dates in acess 2000, the thing is I want
to search for records using a form by date. I will be using a between
date search box. But i want to enter say todays date but retrieve the
results for exactly one month later.
E.G.
I if I enter 10-05-04 to 14-05-04 I want to see the records for
exactly 30/31 days later.
I was thinking could I manipulate the "Today'sDate" function + 30days.
|
by: Cillies |
last post by:
Hi,
I have created a simple update query, that updates the date everyday.
i.e. any date before today's date will be updated to todays date. I
have it running on an autoexec. macro
But I want to be able to update it every 7 days, but at the same time
take into consideration the weekends. I just want to use the 5 working
days of the week (Mon-Fri)and not the weekends (Sat, Sun). for
example, if today is Tuesday and I have 37 date...
|
by: tangokilo |
last post by:
Hi,
I am at a loss! So please excuse me as a true novice at this....!!!
How can I compare dates in a windows form (not web form) using VB.NET and
SQL 2000?
For example, one date is blank (the ending date) the other (starting) date
is 15 Feb 2004 for arguments sake. How do I do this and what methods can I
use? Oh, I am also using Microsofts Data Access Block v2....
|
by: PC Datasheet |
last post by:
An Access user saw my name in a newsgroup and sent me a request for help on
a project. As part of the project, a list of the dates in a month was
needed. For anyone needing a list of dates in a month, here is what I used:
1. Create a table named TblNumbers with one field named Num and populate
the table with 1 to 31
2. Create a query based on TblNumbers
3. Pull down Num into the first field of the query.
4. Put the following...
| |
by: Tim Chase |
last post by:
I've been trying to come up with a good algorithm for determining
the starting and ending dates given the week number (as defined
by the strftime("%W") function).
My preference would be for a Sunday->Saturday range rather than a
Monday->Sunday range. Thus,
>>> startDate, stopDate = weekBoundaries(2006, 23)
would yield a start-date of June 4, 2006 and an end-date of June
|
by: Elainie |
last post by:
I need to get the dates between now and next week but using Now and
Next week not any
specific dates...
Please help, going mad...
Elaine
|
by: soni2926 |
last post by:
Hi,
I have a web application, asp.net and c# done in 2.0, which is going
to return rows from the db with dates or certain events. The db is
going to have events dates for the entire year, but on the site we
just want those events for the current month. Is there a way to check
this, check as each date is returned if it falls under the current
month, year?
Thanks.
|
by: Samir |
last post by:
Is there a way to loop or iterate through a list/tuple in such a way
that when you reach the end, you start over at the beginning? For
example, suppose I define a list "daysOfWeek" such that:
If today is Sunday, I can set the variable "day" to today by:
sunday
If I want to find out the day of the week 2 days from now, then this
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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
| |