I have two textfields one is containing "From Date" and another one is containing "To date" based on that how to filter array of dates.
Asked
Active
Viewed 498 times
-1
-
1Update your question with relevant code that you tried! – iPatel Oct 17 '17 at 05:28
-
Parse textfield strings into dates and then filter dates that are lowe than start date and higher then end date. – Sulthan Oct 17 '17 at 05:35
-
Your requirement is not understandable completely, could you please add more details with the help of some code too !!! – Oct 17 '17 at 05:39
-
[https://stackoverflow.com/questions/24669902/nspredicate-to-filter-between-two-dates-of-nsstring-type](https://stackoverflow.com/questions/24669902/nspredicate-to-filter-between-two-dates-of-nsstring-type) – Ketan Parmar Oct 17 '17 at 05:44
-
i didn't Try other code my requirements is i have two textfields. one textfield is "From date" Textfield and another Textfield Is "TO date". i am getting array of dates from server once user entered From and To date the events array should be filtered with From and to dates. @ipatel @ K.R.Saravana Kumar – kishore Oct 17 '17 at 06:59
1 Answers
0
you have two date first is starting date and other in ending date and other is date that check in between of start and end date or not..
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd"// before formate
let date_selected = format.date(from: date)
format.dateFormat = "dd-MM-yyyy"// change related to my format
let seldate_selected = format.string(from: date_selected!)
let dt = format.date(from: seldate_selected)
let str_dat = format.date(from: startDate)
let end_dat = format.date(from: endDate)
if dt! >= str_dat! && dt! <= end_dat!
{
print("selected date is not in between start date and end date ")
}
else
{
print("selected date is not in between start date and end date ")
}

Sagar Bhut
- 657
- 6
- 28
-
let date_selected = format.date(from: date) in this line of code from where you are taking date? – kishore Oct 17 '17 at 10:49