cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Giulian
Advocate I
Advocate I

Filter by month on my datastore fields contains data

Hi

 

I Search to filter my data gallery by month

 

- I have a CDS datastore with a field where a date of an events is store

- When user watch events i want he can view all event or view event group by month exemple march 2017

1 ACCEPTED SOLUTION

Accepted Solutions

I try to understand you re solution

 

For moment i change my way

 

- I use Datepicker for collect a date

- i put the result of Datepicker into a textbox with (DatePicker.SelectedDate; DateTimeFormat.LongDate)

- when i patch my form i collect text of date into my database ( i change datatype of my field)

- In my gallery i create a searchbar where i search for date.text

- then when i type march or march 2017 i see events

View solution in original post

3 REPLIES 3
Meneghino
Community Champion
Community Champion

Hi @Giulian

You can use AddColumns to add the YearMonth column and then a Filter function to filter by the desired year-month combination.

 

Something like this:

Filter(AddColumns(MyCDSentity, "YearMonth", Text(Year(MyDateField))&"-"&Text(Month(MyDateField), "00")), YearMonth = "2017-03")

I try to understand you re solution

 

For moment i change my way

 

- I use Datepicker for collect a date

- i put the result of Datepicker into a textbox with (DatePicker.SelectedDate; DateTimeFormat.LongDate)

- when i patch my form i collect text of date into my database ( i change datatype of my field)

- In my gallery i create a searchbar where i search for date.text

- then when i type march or march 2017 i see events

View solution in original post

Meneghino
Community Champion
Community Champion

Hi again @Giulian, well done for your clever solution.

In my example I assumed that you stored dates as dates and not as text.

Actually storing dates as text is much better in many situations (especially to avoid time zone related problems), but in that case the best format is not LongDate but "yyyy-mm-dd", which is a worldwide standard. So today would be 2017-03-16 as text.

You can then get the date in any format you want, for example like this:

Text(DateValue("2017-03-16"), DateTimeFormat.LongDate)

This is just a thought.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (59,094)