Reputation: 910
I'm struggling with a problem about Dates manipulation.
Background :
Access 2013 - Classic Stock Table (id, name_item, record_date)
Currently working on SearchForm. Have to finish the last filter (dates) - Others filters work.
I designed a ComboBox to filter "< 7 days", "< 30 days",...
PBM : Date format is d/m/y (french format)
Operator < seems to compare with m/d/y even my date are defined in d/m/y. I verified both Type in Table and Date(), they're set in d/m/y
CODE :
If InputDate.Value = "La semaine derniere" Then
strfilter = strfilter & "([Record_date] > #" & DateAdd("d", -7, Date) & "#)"
Debug.Print Month(DateAdd("d", -7, Date)) & " " & strfilter
Output :
9 ([Record_date] > #03/09/2015#)
I tried also strfilter = strfilter & "(Datediff('d', date(), [Record_date]) < 7)"
No difference :'(.
Any idea how I can go through this problem please.
Falt
Upvotes: 0
Views: 89
Reputation: 56026
You need the date value as a string expression formatted to yyyy/mm/dd:
strfilter = strfilter & "([Record_date] > #" & Format(DateAdd("d", -7, Date), "yyyy\/mm\/dd" & "#)"
Upvotes: 2