I had issues with this and I haven\'t found a proper answer on SO so I\'ll leave a small tutorial here.
The goal is to filter fetched objects by today\'s date.
In swift4, Lawrence413's can be simplify a bit:
//Get today's beginning & end let dateFrom = calendar.startOfDay(for: Date()) // eg. 2016-10-10 00:00:00 let dateTo = calendar.date(byAdding: .day, value: 1, to: dateFrom)
It get rid of the component part, makes the code have better readability.
component