如何在Postgres中获取daterange的开始和结束日期?

时间:2016-11-21 09:10:23

标签: sql postgresql

我在表格中有import UIKit class TableViewController: UITableViewController, UISearchBarDelegate, UISearchDisplayDelegate { var data:[MyData] = [] @IBOutlet weak var searchBar: UISearchBar! var searchActive : Bool = false var filtered:[MyData] = [] override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self tableView.dataSource = self searchBar.delegate = self } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } override func numberOfSections(in tableView: UITableView) -> Int { return 1 } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if(searchActive) { return filtered.count } else { return data.count } } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "segue", for: indexPath) if(searchActive) { cell.label1.text = filtered[indexPath.row].data1 cell.label2.text = filtered[indexPath.row].data2 cell.label3.text = filtered[indexPath.row].data3 cell.label4.text = "\(filtered[indexPath.row].data4) ₺" cell.label5.text = filtered[indexPath.row].data5 } else { cell.label1.text = data[indexPath.row].data1 cell.label2.text = data[indexPath.row].data2 cell.label3.text = data[indexPath.row].data3 cell.label4.text = "\(data[indexPath.row].data4) ₺" cell.label5.text = data[indexPath.row].data5 } cell.backgroundColor = UIColor.clear cell.selectionStyle = UITableViewCellSelectionStyle.none return cell } func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { searchActive = true; } func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { searchActive = false; self.searchBar.endEditing(true) } func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { searchActive = false; self.searchBar.endEditing(true) } func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { searchActive = false; self.searchBar.endEditing(true) } func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { filtered = data.filter { $0.data1.localizedCaseInsensitiveContains(searchText) } if(filtered.count == 0){ searchActive = false; } else { searchActive = true; } self.tableView.reloadData() } } 类型列。我想选择所有在日期范围内具有结束日期的行。

我可以以某种方式提取查询中日期范围的起始值和结束值吗?

1 个答案:

答案 0 :(得分:1)

我想,您可以使用upper(anyrange)函数来获取此值。根据{{​​3}}。

类似的东西:

SELECT * FROM table_name
WHERE upper(daterange_type_colum) > current_date();