[web2py] Re: Difference of two date field in years

2016-12-11 Thread Brian M
Like Anthony said, without seeing your code we can't help. What exactly do 
you mean by "is not able to recognize date fields as date"? 

As an alternative to dateutil you could also look into the Pendulum package 
(https://pendulum.eustace.io/) which makes playing with dates even easier.

On Friday, December 9, 2016 at 10:31:37 AM UTC-6, Amit Kumar Modak wrote:
>
> How to get the difference of two date field in years.
> dateutil.relativedelta.relativedelta is not working as it is not able to 
> recognise date fields as date.
>
> Thanks,
> Amit
>

-- 
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] Re: Difference of two date field in years

2016-12-09 Thread Dave S


On Friday, December 9, 2016 at 8:31:37 AM UTC-8, Amit Kumar Modak wrote:
>
> How to get the difference of two date field in years.
> dateutil.relativedelta.relativedelta is not working as it is not able to 
> recognise date fields as date.
>
>
>
datetime.timedelta ?



If you subtract 2 datetime.datetime objectss or 2 datetime.date objects, 
you get a datetime.timedelta which will tell you the number of days, and 
then you divide by 365, or 365.25 if you expect leap years to be important 
(it will be a while before the skip rules apply; we're 16 years past the 
last one).

datetime has several ways of making date objects, and web2py uses some of 
them.  If you just have a time from the usual epoch, then the python time 
module might help.
.

/dps
 

-- 
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] Re: Difference of two date field in years

2016-12-09 Thread Anthony
On Friday, December 9, 2016 at 11:31:37 AM UTC-5, Amit Kumar Modak wrote:
>
> How to get the difference of two date field in years.
> dateutil.relativedelta.relativedelta is not working as it is not able to 
> recognise date fields as date.
>

Always show your code.

-- 
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.