Re: [web2py] How to strip away and get rid of (… days, 0:00:00) from a value acquired from a date calculation
It works SP, thank you. Regards: Mostwanted On Thursday, October 25, 2018 at 7:17:03 PM UTC+2, sandeep patel wrote: > > > > > > > > > *You can directly count days from date type.this belongs to datetime > class.db.define_table('hotels',Field('Hotel'), > Field('Bookin', 'date'),Field('Bookout', 'date'), > Field('days', compute=lambda r: (r['Bookout']-r['Bookin']).days), > Field('guests', 'integer'),Field('price', compute=lambda r: > r['days']*r['guests']*650))Let me know if this will work for you.ThanksSP* > > On Thu, Oct 25, 2018 at 9:50 PM mostwanted > wrote: > >> I have 4 values that have to be calculated together to set a default >> value for the fifth value, 2 of the 4 values are date values but the >> problem is that calculating their difference leaves *days, 0:00:00* as >> part of the answer but i only want the value number they give, is there a >> way to strip away the *days, 0:00:00* from the date calculation answer >> so i could use the remaining value in my calculation and get the answer i >> want? >> >> >> *Example Code* >> >> >> *MODEL:* >> >> >> >> >> >> >> >> >> *db.define_table('hotels',Field('Hotel'), >> Field('Bookin', 'date'),Field('Bookout', 'date'), >> Field('days', compute=lambda r: r['Bookout']-r['Bookin']), >> Field('guests', 'integer'),Field('price', compute=lambda r: >> r['days']*r['guests']*650))* >> >> Regards: >> >> >> Mostwanted >> >> -- >> 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+un...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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.
Re: [web2py] How to strip away and get rid of (… days, 0:00:00) from a value acquired from a date calculation
*You can directly count days from date type.this belongs to datetime class.db.define_table('hotels',Field('Hotel'), Field('Bookin', 'date'),Field('Bookout', 'date'), Field('days', compute=lambda r: (r['Bookout']-r['Bookin']).days), Field('guests', 'integer'),Field('price', compute=lambda r: r['days']*r['guests']*650))Let me know if this will work for you.ThanksSP* On Thu, Oct 25, 2018 at 9:50 PM mostwanted wrote: > I have 4 values that have to be calculated together to set a default value > for the fifth value, 2 of the 4 values are date values but the problem is > that calculating their difference leaves *days, 0:00:00* as part of the > answer but i only want the value number they give, is there a way to strip > away the *days, 0:00:00* from the date calculation answer so i could use > the remaining value in my calculation and get the answer i want? > > > *Example Code* > > > *MODEL:* > > > > > > > > > *db.define_table('hotels',Field('Hotel'), > Field('Bookin', 'date'),Field('Bookout', 'date'), > Field('days', compute=lambda r: r['Bookout']-r['Bookin']), > Field('guests', 'integer'),Field('price', compute=lambda r: > r['days']*r['guests']*650))* > > Regards: > > > Mostwanted > > -- > 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. > -- 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.
[web2py] How to strip away and get rid of (… days, 0:00:00) from a value acquired from a date calculation
I have 4 values that have to be calculated together to set a default value for the fifth value, 2 of the 4 values are date values but the problem is that calculating their difference leaves *days, 0:00:00* as part of the answer but i only want the value number they give, is there a way to strip away the *days, 0:00:00* from the date calculation answer so i could use the remaining value in my calculation and get the answer i want? *Example Code* *MODEL:* *db.define_table('hotels',Field('Hotel'), Field('Bookin', 'date'),Field('Bookout', 'date'), Field('days', compute=lambda r: r['Bookout']-r['Bookin']), Field('guests', 'integer'),Field('price', compute=lambda r: r['days']*r['guests']*650))* Regards: Mostwanted -- 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.