471,337 Members | 1,140 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

mod_python, dates, strings and integers

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.

Jan 26 '06 #1
0 809

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by wireless200 | last post: by
22 posts views Thread by mike | last post: by
2 posts views Thread by Robert J. Hansen | last post: by
reply views Thread by Python_it | last post: by
6 posts views Thread by Anthony L. | last post: by
1 post views Thread by treelife | last post: by

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.