On Monday, April 18, 2016 at 1:15:59 PM UTC-7, Steve Joe wrote:
>
> suppose I have two datetime as following. Now how do I compare between 
> both and return true if time gap between both is 4 seconds or not. I am 
> confused because they are none type objects so how to compare them?
>  2016-04-19 01:25:09.9090
> 2016-04-19 01:25:09.8765
>

What do you mean they are none type objects? 

If you have a datetime.datetime object, then you subtract one from the 
other to get a datetime.timedelta object, and compare that to the allowed 
difference.

<URL:https://docs.python.org/2/library/datetime.html#datetime-objects> 
Scroll down below the constuctors and class attributes to a little table; 
result (3) is your guide.


If you have string objects, than you'd use the datetime.datetimestrptime() 
constructor to get you datetime objects, and then compare as above.

If you have none type objects, you have nothing.

/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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to