I there a way to select dates using a button? I need to add a button that dynamically selects the last 7 days based on the current date.
I tried the following, without any luck:
Does the format of ItemCreatedDate can influence the result? In this case, the format is "YYYY-MM-DD hh:mm:ss".
Can somebody help me on that one?
Yes it may not work because of the format..
today() is a date and Date(today()) is a date also
your field ItemCreatedDate is a TIMESTAMP, you should interpret this field and format it as a date before, you can create a derived field in the script like this:
Date(Date#(ItemCreatedDate , 'the format you have on the DateFormat variable ')) as new_field_name
! on the button, when you identiy the Date field, make you to not put = sign !
Perhaps this? Or please post application to test, If dates are real date format then this should work
='>=' & Date(Max(ItemCreatedDate-7), 'YYYY-MM-DD') & '<=' & Date(Today(), 'YYYY-MM-DD')
Yes I beleive the format influence the result.. As a test you can try the very same search string in the search box for a List Box object containing the field you wish to search.
Actually you can (and perhaps should?) remove the time part from your ItemCreatedDate if only the date part is relevant.
Else try the following script in an empty app to examine some options for creating a timestamp for your button:
date(Today()-7) as Today,
timestamp(Now()-7) as Now,
timestamp(Date(Today()-7) & ' 00:00:00') as Timestamp,
Date(Today()-7) & ' 00:00:00' as Text