Questions tagged [date-comparison]

This tag refers to the process of comparing two or more dates with one another.

Use this tag for any questions related to date comparison.

302 questions
158
votes
5 answers

Comparing Dates in Oracle SQL

I'm trying to get it to display the number of employees that are hired after June 20, 1994, Select employee_id, count(*) From Employee Where to_char(employee_date_hired, 'DD-MON-YY') > 31-DEC-95; But I get an error saying "JUN' invalid…
user1336830
  • 1,581
  • 2
  • 10
  • 3
72
votes
14 answers

How to compare two dates in Objective-C

I have two dates: 2009-05-11 and the current date. I want to check whether the given date is the current date or not. How is this possible.
Raju
  • 3,389
  • 12
  • 34
  • 29
66
votes
8 answers

Getting date list in a range in PostgreSQL

I'd like to get the list of days between the two dates (including them) in a PostgreSQL database. For example, if I had: start date: 29 june 2012 end date: 3 july 2012 then the result should be: 29 june 2012 30 june 2012 1 july 2012 2 july 2012…
Javi
  • 17,777
  • 30
  • 97
  • 132
47
votes
8 answers

Comparing dates in MySQL ignoring time portion of a DateTime field

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…
Tiny
  • 24,933
  • 92
  • 299
  • 571
34
votes
4 answers

Difference between 2 dates in weeks and days using swift 3 and xcode 8

I am trying to calculate the difference between 2 dates (one is the current date and the other from datepicker) in weeks and days then displaying the result on a label, that's what i have done so far, i appreciate the help of more experienced…
FormulaOne
  • 339
  • 1
  • 3
  • 7
27
votes
11 answers

Get most recent date from an array of dates

I have the array of dates below array(5) { [0]=> string(19) "2012-06-11 08:30:49" [1]=> string(19) "2012-06-07 08:03:54" [2]=> string(19) "2012-05-26 23:04:04" [3]=> string(19) "2012-05-27 08:30:00" [4]=> string(19)…
sugarFornaciari
  • 283
  • 1
  • 3
  • 7
21
votes
6 answers

compare string with today's date in JavaScript

I've got a string from an input field which I use for date with a format like this 25-02-2013. Now I want to compare the string with today's date. I want to know if the string is older or newer then today's date. Any suggestions?
Leon van der Veen
  • 1,498
  • 9
  • 40
  • 57
13
votes
7 answers

Comparing dates in jquery

I am having the following codes and it though i'm having 01-Jan-2009 for DateTo and 03-Jan-2009 for DateFrom it's reading the values as NAN. Am I missing anything? I`m referencing var DateToValue = $("#DateTo").val(); var DateFromValue =…
learning
  • 10,375
  • 33
  • 84
  • 152
9
votes
8 answers

Oracle use LIKE '%' on DATE

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…
Mihawk
  • 727
  • 3
  • 12
  • 25
8
votes
2 answers

Equality comparison between Date and number doesn't work

According to the ECMA script standard, the following code should return true, but it doesn't: d = new Date() ; d.setTime(1436497200000) ; alert( d == 1436497200000 ) ; Section 11.9.3 says: If Type(x) is either String or Number and Type(y) is…
GetFree
  • 34,030
  • 17
  • 70
  • 101
8
votes
3 answers

Comparing dates ignoring the seconds and the milliseconds instant of DateTime in Joda

Let's assume that I have two dates like the following. DateTimeFormatter formatter = DateTimeFormat.forPattern("dd-MMM-yyyy HH:mm:ss").withZone(DateTimeZone.forID("Asia/Kolkata")); DateTime firstDate = formatter.parseDateTime("16-Feb-2012…
Tiny
  • 24,933
  • 92
  • 299
  • 571
7
votes
2 answers

PostgreSql + Date Format Convert YYYY-MM-DD to Day, Date Month Year

Suppose I am storing this format in my postgre database table. Now I have to compare this date with one of the texbox value contain date in different format. Database Date Format :: YYYY-MM-DD For example :: 2010-11-26 Text-Field Date Format ::…
Rubyist
  • 6,247
  • 8
  • 46
  • 83
7
votes
4 answers

how to compare date in swift 3.0?

I have two dates and I want to compare it. How can I compare dates? I have to date objects. Say modificateionDate older updatedDate. So which is the best practice to compare dates?
Ashwin Indianic
  • 931
  • 2
  • 10
  • 21
7
votes
4 answers

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

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 …
moxmlb
  • 692
  • 3
  • 8
  • 15
7
votes
1 answer

Why do 2 time structs with the same date and time return false when compared with ==?

I have a time.Time created using time.Date(). I then calculate the number of nanoseconds between 1970/1/1 00:00:00.000000000 and that time. I then take the nanoseconds and turn them back into a time.Time using time.Unix(). However, if I compare the…
F21
  • 28,366
  • 23
  • 91
  • 157
1
2 3
20 21