2016-11-30 43 views
1

我试图查看选定基础上几个月甚至几年查询:我已经得到选定的日期是作为申报(// dateselectedStr =“2016-11” )查询包含日期

并且在线数据库中的存储日期包含更新日期与2016-11相同,我如何根据拥有.contain搜索查询?这是我的小径

query.order(byDescending: "updatedAt") 
if PFUser.current() != nil { 


query.whereKey(CARD_UPDATED_AT, contains: dateselectedStr) 

query.findObjectsInBackground { (objects, error)-> Void in 
    if error == nil { 
     self.recipesArray = objects! 
     // Reload CollView 
     self.recipesCollView.reloadData() 
     let counter = (objects!.count) 
     print(counter) 
     self.title = "\(counter) JOB CARDS" 
     self.hideHUD() 

     // Hide/show the nothing found Label 
     if self.recipesArray.count == 0 { self.nothingFoundLabel.isHidden = false 
     } else { self.nothingFoundLabel.isHidden = true } 

    } else { 
     self.simpleAlert("\(error!.localizedDescription)") 
     self.hideHUD() 
}} 

回答

0

AFAIK,这是唯一可行的解​​决方案

对于2016年,

updatedAt> = 2016年1月1日& updatedAt < = 31-12-2016

对于一月,

updateAt> = 2016年1月1日& updatedAt < = 31-01-2016

希望这有助于:)