Hi Everyone;
I hardly ever post as I can usually find answers to my questions but I have 
been having a hard time with this datetime stuff. When I run the code in 
db1.py (minus the databse code) with pycharm I get the correct results. 
Running it in Web2py I get the correct dates but it gives 3 sets of them. 
I'm sure it's simple but I can't figure it out. Any help appreciated. 
Thanks....



*db1.py*
db.define_table('datein',
    Field('date_in'),
    )

import datetime
from datetime import date, timedelta
import calendar

weekNumber = date.today().isocalendar()[1]

today = datetime.date.today()

td = str(today)

dt = datetime.datetime.strptime(td, '%Y-%m-%d')

start = dt - timedelta(days=dt.weekday())

end = start + timedelta(days=6)

step = datetime.timedelta(days=1)
while start <= end:
    blah = start.strftime('%Y-%m-%d')
    db.datein.insert(date_in=blah)
#    if not db(db.datein).count():
    start += step

*Result*
21 selected
datein.id 
<http://127.0.0.1:8000/testinput/appadmin/select/db?orderby=datein.id>
datein.date_in 
<http://127.0.0.1:8000/testinput/appadmin/select/db?orderby=datein.date_in>
545 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/545> 
2016-04-25
546 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/546> 
2016-04-26
547 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/547> 
2016-04-27
548 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/548> 
2016-04-28
549 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/549> 
2016-04-29
550 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/550> 
2016-04-30
551 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/551> 
2016-05-01
552 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/552> 
2016-04-25
553 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/553> 
2016-04-26
554 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/554> 
2016-04-27
555 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/555> 
2016-04-28
556 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/556> 
2016-04-29
557 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/557> 
2016-04-30
558 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/558> 
2016-05-01
559 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/559> 
2016-04-25
560 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/560> 
2016-04-26
561 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/561> 
2016-04-27
562 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/562> 
2016-04-28
563 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/563> 
2016-04-29
564 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/564> 
2016-04-30
565 <http://127.0.0.1:8000/testinput/appadmin/update/db/datein/565> 
2016-05-01

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to