Have you tried changing --

    hourminute=str(request.now.hour) + ':' + str(request.now.minute)

to

    if len(str(request.now.hour)) < 2 :
       hourminute= '0'+str(request.now.hour) + ':' + str
(request.now.minute)
    else
       hourminute=str(request.now.hour) + ':' + str
(request.now.minute)

lack of '0' would give you a 'no match' against the database.


On Jun 22, 3:10 am, annet <[email protected]> wrote:
> In my model I defined:
>
> db.define_table('timetable',
>     db.Field(...),
>     db.Field('day',db.day,default='',notnull=True),
>     db.Field('time',length=5,default='',notnull=True),
>     db.Field(...),
>     migrate='timetable.table')
>
> In a view I would like to display today's upcoming programs, the
> function reads like:
>
> weekday=request.now.weekday() + 1
>     hourminute=str(request.now.hour) + ':' + str(request.now.minute)
>     timetable=db((db.timetable.day==weekday)&
> (db.timetable.time>=hourminute))\
>     .select(db.timetable.ALL,orderby=db.timetable.time,limitby=(0,6))
>
> The problem is that in the database the time reads like 09:45 whereas
> hourminute reads like 9:30, consequently the query doesn't return any
> results before 10:00, after 10:00 it works alright.
>
> I tried making time a field of type datetime, format it like '%H:%S'
> and then do: db.timetable.time>=request.now But a field of type
> datetime makes the calendar pop up and that doesn't allow me to enter
> times like 09:45.
>
> I wonder whether request.now.hour is able to return the hours in a
> different format. Else, I guess I have to write a custom function to
> get the hours formatted correctly.
>
> Kind regards,
>
> Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to