Re: [sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Jonathan Vanasco
> The only difference between my code and yours is that I am not using sessions. The Flask-Sqlalchemy package handles all the session stuff automatically in the background. The code you write is not interacting with the session explicitly, but it is utilizing the session implicitly. IMHO,

Re: [sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Nancy Andeyo
The solution that finally worked for me is: *from sqlalchemy import extract #monthly_events = current_user.followed_events().filter(Event.event_date < datetime.today().date()).filter(extract('month', Event.event_date) ==

Re: [sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Nancy Andeyo
The only difference between my code and yours is that I am not using sessions. Might it be the reason why my query is not working as expected? Here is my query one more time: monthly_events = current_user.followed_events().filter(Event.event_date <

Re: [sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Nancy Andeyo
The only difference between my code in is that I am not using session. Might it be the reason why my query is not working as expected? Here is my query one more time: monthly_events = current_user.followed_events().filter(Event.event_date < datetime.today().date()).filter(func.strftime('%m',

Re: [sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread James Paul Chibole
Sorry, it is a type, it should actually be .filter(func.strftime('%m', Event.event_date == datetime.today().strftime('%m'))) Let me go through your latest response and will get back to you. Thank you for the prompt response. On Wed, Apr 5, 2023 at 10:16 AM Lele Gaifax wrote: > Nancy Andeyo

[sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Lele Gaifax
Nancy Andeyo writes: > However, the part with problems is this one: .filter(func.strftime('%m', > Event.event_date = datetime.today().strftime('%m'))) where the aim to > filter out events that will take place in the current month. This is the > section that I posted, yet I needed to post the

Re: [sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Nancy Andeyo
Hi Lee, thanks for responding. The code was only part of the entire query, perhaps I needed to provide the entire query and try to explain and give an explanation a little bit. Here is the entire code: monthly_events = current_user.followed_events().filter(Event.event_date <

Re: [sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Nancy Andeyo
Hi Lee, thanks for responding. The code was only part of the entire query, perhaps I needed to provide the entire query and try to explain and give an explanation a little bit. Here is the entire code: monthly_events = current_user.followed_events().filter(Event.event_date <

[sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Lele Gaifax
Nancy Andeyo writes: > the filter *.filter(func.strftime('%m', func.date(Events.date_of_event) == > datetime.today().strftime('%m')))* to get all the events that happened in > the current month is not working. But displays all the events. Read carefully what you have written: >