Dropping that field and creating a new one got it working.  

Thanks everyone, I've gotten a lot of really good help on this group since 
picking up web2py.  Much appreciated!

On Friday, March 1, 2013 8:20:41 PM UTC-5, Mark wrote:
>
> I am wrong in the second case. It seems that date() cannot be used in a 
> query that way, sorry.
>
> For the first case, Field('appointment_date', 'date') should work. I have 
> similar fields in my program without any problems. I think you may need to 
> drop the old table and re-create a new table because there may be some 
> conflict. Or try to define a new field or define a brand new table, and use 
> requires=IS_DATE() for the field. It is easier to test by a new table.
>
> Mark
>
> On Friday, March 1, 2013 7:06:01 PM UTC-5, jjg0 wrote:
>>
>> I may have marked this answered a bit too early.  Here are more problems 
>> I am seeing:
>>
>> 1. If you only need date, use Field('appointment_date', 'date') instead
>>>
>>
>> Using  Field('appointment_date', 'date') seems to destroy tables.  Does 
>> web2py even have a working Field('...', 'date')?  When adding a field set 
>> to 'date' in a table, all I see is 'Query Not Supported: need more than 1 
>> value to unpack' anytime I try to use that table.  Even the admin won't 
>> work anymore.  I am really confused as to why this is or how to fix this.  
>> The only fix seems to be to remove the table entirely.
>>
>> 2.  If you want to keep 'datetime', can do appointment_date.date() also.
>>>
>> I can use appointment_date.date() to print out the date in the correct 
>> format in a view using something like 
>> {{=appointment.appointment_date.date()}}, but if I use it in a query it 
>> seems to fail.  For example, trying:
>>
>> appointments = db(db.appointments.appointments_date.date() == 
>> request.now.date()).select()
>>
>> Gives me an error: 
>>
>> AttributeError: 'Field' object has no attribute 'date'.
>>
>> Is the '.date()' part not allowed in a query?  I am not sure what to make of 
>> this.
>>
>> Any help would be appreciated.
>>
>> On Thursday, February 28, 2013 10:17:37 PM UTC-5, Mark wrote:
>>>
>>> If you only need date, use Field('appointment_date', 'date') instead. If 
>>> you want to keep 'datetime', can do appointment_date.date() also. Mark
>>>
>>> On Thursday, February 28, 2013 8:51:53 PM UTC-5, jjg0 wrote:
>>>>
>>>> Hi Everyone!  I have another 'new guy' question, for those who have 
>>>> been following me so far.
>>>>
>>>> I need to be able to look at two dates and determine if they match 
>>>> while ignoring the time. Specifically, a date vs today
>>>> Lets say I have a model of appointments and in that model there is some 
>>>> appointment date field, so in appointments table we have:
>>>>
>>>> Field('appointment_date', 'datetime'),
>>>>
>>>> and I want to grab today's appointments in a controller:
>>>>
>>>> appointments = db(db.appointments.appointment_date == 
>>>> request.now.date()).select(),
>>>>
>>>> This will be empty because none of the times will match.  (Or maybe 1 
>>>> will if I am extremely lucky to hit the db at that moment the time matches 
>>>> but anyways..)
>>>>
>>>> So far I've found 2 solutions and both have problems:
>>>>
>>>> Solution 1.  Format my Field so that it doesn't have 
>>>> hours/minutes/seconds.  Something like format=('%Y%m%d'), (I may have 
>>>> typed 
>>>> that wrong).  Now this works: 
>>>>
>>>> db.appointments.appointment_date == request.now.date()
>>>>
>>>> The Problem:  The SQLFORMs have this little calendar popup when 
>>>> entering the date in, and this forces you to have the time stamp.  This 
>>>> means any SQLFORMs I have that let the user enter a date will always be 
>>>> broken if you try to use the calendar.  
>>>>
>>>> Solution 2:  query using | (or) like so:
>>>>
>>>> query1 = db.appointments.appointment_date.year() == request.now.year
>>>> query2 = db.appointments.appointment_date.month() == request.now.month
>>>> query3 = db.appointments.appointment_date.day() == request.now.day
>>>>
>>>> appointments = db(query1 | query2 | query3).select()
>>>>
>>>> This works! It's actually what I went with, and everything was going 
>>>> swimmingly!  I didn't have to fiddle with ajax or whatever controls the 
>>>> calendar in the SQLFORMs, although I realize I should get around to 
>>>> learning how to do that at some point. So what's the problem?
>>>>
>>>> The Problem:  Google app engine does not allow this:(  Found this out 
>>>> the hard way.  
>>>>
>>>> So, are there easier ways to check if a datetime field is equal to 
>>>> today?
>>>>
>>>> Thanks for all the help so far.
>>>>
>>>>
>>>> EDIT: spelling
>>>>
>>>

-- 

--- 
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/groups/opt_out.


Reply via email to