Reputation: 33
I'm working with Nepali date and the following date is correct but django don't let me run the query.
search_range = Trans.objects.filter(tr_date__gte='2077-04-01', tr_date__lte='2077-04-32')
I've following code which is working fine if i give date upto 2077-04-30. But according to Nepali calender 4th month has 32 days. When i try to run the query with day 32 django returns following error.
ValidationError at /trans/list/search/
['“2077-04-32” value has the correct format (YYYY-MM-DD) but it is an invalid date.']
Request Method: GET
Request URL: http://127.0.0.1:8000/trans/list/search/
Django Version: 3.1
Exception Type: ValidationError
Exception Value:
['“2077-04-32” value has the correct format (YYYY-MM-DD) but it is an invalid date.']
How can i get the data within mentioned range? Any suggestion is highly appreciated.
Upvotes: 2
Views: 563
Reputation: 46839
Why not just use tr_date__lt='2077-05-01' i.e. just less than 5/1 - I personally have never heard of there being 32 days in any month, but if you just filter for less than 5/1 won't it have the same result?
Upvotes: 1