An old post to solve a 2014 problem. Thanks for sharing! :)
El miércoles, 2 de noviembre de 2011 16:27:23 UTC+1, Vineet escribió: > > Recently, I wrote this function for my purpose. > See if this helps you. > Assuming that argument 'dte' input format is -->> "03-11-2011" > > [CODE] > import datetime, string > > def str_to_dt(dte): > dte = str(dte) > dte = string.strip(dte) > if len(dte) == 10: > y = int(dte[6:]) > m = int(dte[3:5]) > d = int(dte[:2]) > return datetime.date(y, m, d) > [/CODE] > > This returns output in "python datetime.date" format. > > --Vineet > > On Nov 2, 8:19 pm, Omi Chiba <ochib...@gmail.com> wrote: > > This is more like python question but > > > > jj.J2NSD is integer and has value = 20111130 (YYYYMMDD) > > > > I want to set the value as default value of FFNSD which is 'date' > > type. > > > > Field('FFNSD', 'date'), > > > > I think I need to import datetime and convert from integer or stiring. > > Is anyone know easy way to do it ? > > > > This doesn't work because it set string to date... > > > > db.FEDEXFORM.FFNSD.default = str(jj.J2NSD)[0:4]+"-"+str(jj.J2NSD) > > [4:6]+"-"+str(jj.J2NSD)[6:8] -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.