date-comparison

How can i compare two dates (NSDate) in Swift 3 and get the days between them?

自作多情 提交于 2019-12-08 18:41:27
问题 How can I compare two dates in Swift 3? I found many solutions for other Swift versions, but they doesn't work for me. let clickedDay:String = currentcell.DayLabel.text! let currentDate = NSDate() let currentDay = "" //want the current day let dateFormatter = DateFormatter() var dateAsString = "" if Int(clickedDay)! < 10 { dateAsString = "0" + clickedDay + "-11-2016 GMT" } else { dateAsString = clickedDay + "-11-2016 GMT" } dateFormatter.dateFormat = "dd-MM-yyyy zzz" let clickedDate =

Comparing dates from SQL Server linked table in Access

三世轮回 提交于 2019-12-08 06:22:30
问题 I have a SQL Server linked table in Access and I am trying to query to extract from a certain date or data ranges (i.e. < 01/31/2017 , for example). I tried in the criteria in Access design mode, the following: < #01/31/2017# but it is not comparing correctly. The field in the SQL server table is datetime data type, I formatted it in Access as Short Date in the properties in design mode. SELECT dbo_LicensesLiveViewWithRevenue.BAN, dbo_LicensesLiveViewWithRevenue.PTN, dbo

Comparing dates giving incorrect outputs

北慕城南 提交于 2019-12-02 22:49:46
问题 I'm creating a function to check which date, in a database table full of date's, is smaller then then current date. As in the past. I've got 3 date's to test the function with, and the outputs behind them: Date from last month: 28-04-2015 16:32:00 Date yet to come: 11-06-2015 13:12:00 Date from last week: 04-05-2015 09:45:00 $dateNow = date('d-m-Y H:i:s'); //Current $deadlineDate = "28-04-2015 16:33:18"; if($deadlineDate < $dateNow){ //If date from last month is smaller then the current date

Comparing dates?

爷,独闯天下 提交于 2019-12-02 13:36:46
I’m trying to compare two dates in Android but im getting this when I write this SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy"); String valid_until = "26052018"; final Date strDate = sdf.parse(valid_until); and if I put the try and catch like this I can’t compare the date because it says I didn't declared strDate . SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date → text), parsing (text → date), and normalization. Good Approach You should use PROPER Date format. DEMO Date strDate=null; // Declare as

java - compare two date values for the month and year

自作多情 提交于 2019-12-01 11:19:05
I have a requirement to match two dates and if their month/year are same, i should return true, otherwise false. Based on my search, i found the following solution. Is there any other better way to do this comparison?. Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); cal1.setTime(date1); cal2.setTime(date2); boolean sameDay = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH); tl;dr match two dates and if their month/year are same Is there any other better way to do this comparison? Yes, the better way uses

How to determine if the specific time is between given time range in javascript

狂风中的少年 提交于 2019-12-01 06:03:48
i want to check var check_val in between two time var open_time and var close_time var open_time = "23:30"; var close_time = "06:30"; var check_val ="02:30"; if(Date.parse ( check_val ) > Date.parse ( open_time ) && Date.parse ( check_val ) < Date.parse ( close_time )){ var flag=1; } else { var flag=2 } the result is always else part Date.parse() accepts dates in RFC2822 or ISO8601 formats. In your case, it always returns NaN . Date.parse("23:30"); // NaN Using the appropriate Date format works as expected: var open_time = Date.parse("2011-10-09T23:30"); var close_time = Date.parse("2011-10

Oracle use LIKE '%' on DATE

若如初见. 提交于 2019-12-01 04:19:33
My table myTab has the column startDate , which has the datatype "DATE". The data in this column are stored like dd.mm.yyyy . Now I'm trying to get data with this query: SELECT * FROM myTab WHERE startDate like '%01.2015" Somehow it doesn't work and I don't know why. Hope someone can help. To make a text search on the date you would have to convert the date to text. It's more efficient if you calculate the first and last date for what you want to find and get everything between them. That way it's done as numeric comparisons instead of a text pattern match, and it can make use of an index if

How to determine if the specific time is between given time range in javascript

折月煮酒 提交于 2019-12-01 03:23:22
问题 i want to check var check_val in between two time var open_time and var close_time var open_time = "23:30"; var close_time = "06:30"; var check_val ="02:30"; if(Date.parse ( check_val ) > Date.parse ( open_time ) && Date.parse ( check_val ) < Date.parse ( close_time )){ var flag=1; } else { var flag=2 } the result is always else part 回答1: Date.parse() accepts dates in RFC2822 or ISO8601 formats. In your case, it always returns NaN . Date.parse("23:30"); // NaN Using the appropriate Date

Oracle use LIKE '%' on DATE

浪尽此生 提交于 2019-12-01 01:21:30
问题 My table myTab has the column startDate , which has the datatype "DATE". The data in this column are stored like dd.mm.yyyy . Now I'm trying to get data with this query: SELECT * FROM myTab WHERE startDate like '%01.2015" Somehow it doesn't work and I don't know why. Hope someone can help. 回答1: To make a text search on the date you would have to convert the date to text. It's more efficient if you calculate the first and last date for what you want to find and get everything between them.

Comparing dates in MySQL ignoring time portion of a DateTime field

人走茶凉 提交于 2019-11-30 04:14:36
I need to compare dates in MySQL ignoring the time portion in a DateTime column. I have tried the following SQL. SELECT * FROM order_table where order_date=date_format('2012-05-03', '%Y-%m-%d'); It doesn't retrieve any row even though there is a date 2012-05-03 10:16:46 in MySQL table. How can the time portion in the DateTime field be ignored while comparing dates in MySQL? Mark Byers You could use the DATE function: SELECT col1, col2, ..., coln FROM order_table WHERE date(order_date) = '2012-05-03' But this is more efficient, if your table is large and you have an index on order date : SELECT