I had some fun with this

max_age_allowed = 20 * 60  # total seconds in 20 minutes
update_age = request.now - person.created_on  # Duration in datetime format 
since record created
update_age = update_age.total_seconds()       # Duration converted to seconds
print "It is %s seconds since record created (threshold is %s seconds)" % 
(update_age,max_age_allowed )
if update_age > max_age_allowed:
    print 'Do something'
else:
    print 'Nothing to do here'



output

It is 2102030.41814 seconds since record created (threshold is 1200 seconds)
Do something

Hope this helps.





On Thursday, 19 July 2012 10:05:41 UTC+1, Amit wrote:
>
> Hi,
> I have some records in a table and each record is having one field of type 
> datetime [fromat : 2012-07-19 23:12:0 (YYYY-MM-DD HH:MM:SS)], table 
> structure is:
>
> Emp_ID
> Emp_Name
> Emp_Address
> Emp_Salary
> updated_on(Type: datetime)
>
> periodically getting data against each Emp_ID and updating to the 
> particular record, every 20 mins data has to be updated for each Emp_ID, 
> for e.g : suppose for one Emp_ID data has updated on 2012-07-19 10:10:00 
> then again it has to update on 2012-07-19 10:30:00 etc...
>
> and if data is not updated in 20 mins then one scheduler will verify 
> against the updated_on column value and inform user that data has not 
> updated  for particular employee.
>
> Problem facing:
> How to compare current datetime with updated_on coulmn value in web2py? 
> can anybody please share me the code to achieve the same?
>

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