472,354 Members | 2,221 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Printing list of dates starting today

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
Sep 1 '08 #1
2 2172
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.today()
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.timedelta(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>

Sep 1 '08 #2
On 2008-09-01, Luka Djigas <ldigas@remove_this.gmail.comwrote:
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(time.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
Sep 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
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? ...
3
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...
2
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...
1
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...
18
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...
3
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...
5
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
5
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...
4
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: ...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.