Questions tagged [datetime-comparison]

102 questions
-1
votes
1 answer

Comparing AM and PM (NSDate)

I have two times both in String format: timeOne = "12:58 AM" timeTwo = "1:05 PM" I convert them into NSDate like this func convertTime(tim: String) -> NSDate{ let strDate = tim let dateFormatter = NSDateFormatter() dateFormatter.dateFormat =…
Minhal Khan
  • 301
  • 3
  • 11
-1
votes
1 answer

Is there a way to combine these 2 methods for DateTime and TimeSpan comparisons

Is there a way to combine these 2 methods for DateTime (ignore the ticks while comparing datetimes) and TimeSpan comparisons with generic parameter types and consolidating the logic? private bool AreDateTimesEqual(DateTime? firstDateTime,…
Steelbird
  • 49
  • 6
-1
votes
4 answers

Compare date in linq

I have a string 31-10-2014 wich i want to compare with a value in the database. public ActionResult SearchResult(string searchDate) { var bookings = from m in db.Bookings select m; if (!String.IsNullOrEmpty(searchDate)) …
Sven van den Boogaart
  • 11,833
  • 21
  • 86
  • 169
-2
votes
2 answers

Java code to compare date and time of an application with the system

I am into automation testing, selenium and java. I have been asked this question in an interview that suppose we have an application which displays date and time. How can we fetch that and compare with the system date and time to ensure that the…
-2
votes
2 answers

How we can find currentDate is in date range or not

I get three dates: From date, To date and current date. I want to find whether current date is in between From and To dates. If current date is in between these two dates then I want to create two new From and To dates. Example: From Date = 15…
y2k
  • 79
  • 1
  • 6
-2
votes
3 answers

PHP Check for time differences

I'm looking for a lean way to compare two times. One is the time, someone requested a new password(FOS UserBundle provides a Getter for that) and the other is the current time minus e.g. 10 minutes. if($user->getPasswordRequestedAt() <= date("Y-m-d…
sonja
  • 924
  • 1
  • 21
  • 52
-2
votes
3 answers

Why does java.sql.Timestamp extend java.util.Date

When I saw this I got baffled: public class Timestamp extends java.util.Date { //... public boolean equals(java.lang.Object ts) { if (ts instanceof Timestamp) { return this.equals((Timestamp)ts); } else { return…
estani
  • 24,254
  • 2
  • 93
  • 76
-3
votes
2 answers

How can I compare two hours in java?

I want to calculate restaurant's opened hours. I have two string, for example: String start_hour = "09:00"; String end_hour = "18:00"; And current hour for example: Calendar now = Calendar.getInstance(); String current_hour =…
Benfactor
  • 543
  • 4
  • 11
  • 31
-3
votes
3 answers

How to convert two different string dates into a single date format

I have two strings that I want to convert into a particular date time format so I can do a comparison. Problem I have is that it errors out in the parse with an exception and I wonder if I am doing something wrong. Wanted to ask what is the best way…
BruceyBandit
  • 3,978
  • 19
  • 72
  • 144
-3
votes
3 answers

How can I compare two different timestamps?

I have written this code to compare two time values in milliseconds. The comparison is of current time with the time defined in the database. fun check_for_lecture(complete:(Boolean) -> Unit) : Int{ for (x in…
avi silwal
  • 31
  • 1
  • 7
-3
votes
2 answers

Any ideas on how I could compare 2 dates in string format?

Any ideas on how I could compare 2 dates in string format: String1 = "Wed May 18 00:00:00 CDT 2011" String2= "May. 18, 2011" I tried converting String1 to date format of String2 but was not very successful. I tried converting String1 to date using…
-4
votes
3 answers

Java LocalDate / LocalDateTime - Hour Between

How do I know if an hour is between two schedules? Example: 10:00 is between 8:00 and 12:00? 7:30 is between 8:00 and 12:00? I'm trying this way: LocalDateTime s = LocalDateTime.of (2017, 10, 20, 8, 00); LocalDateTime f = LocalDateTime.of (2017,…
Mamga
  • 121
  • 2
  • 12
1 2 3 4 5 6
7