mod_python, dates, strings and integers

M

marc.wyburn

when POSTing a date from an mod_python psp page to another the date is
sent as a string. I'm using form.has_key to pull the POST. I can cut
the string up,turn the strings into integers and then use
datetime.datetime(y,m,d,hr,mn,se) to create a proper datetime. Is
there a simpler way of doing this. I ask as I'm working with SQL and
want to keep as much possible in datetime format to avoid confusion/
errors.

snippet

post is; "monday - 01/01/2006"

if form.has_key('day'):
string_day = form['day']
textday = string_day.split("-",1)[0]
pyday = string_day.split("-",1)[1]
d,m,y = pyday.split('/',2)
d = int(d)
m = int(m)
y = int(y)
today = datetime.datetime(y,m,d)



Thanks, Marc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top