Questions tagged [datetime-comparison]

102 questions
136
votes
9 answers

How to do date/time comparison

Is there any options in doing date comparison in Go? I have to sort data based on date and time - independently. So I might allow an object that occurs within a range of dates so long as it also occurs within a range of times. In this model, I could…
eatonphil
  • 13,115
  • 27
  • 76
  • 133
120
votes
15 answers

How to compare only date components from DateTime in EF?

I am having two date values, one already stored in the database and the other selected by the user using DatePicker. The use case is to search for a particular date from the database. The value previously entered in the database always has time…
pencilslate
  • 12,958
  • 18
  • 58
  • 73
56
votes
11 answers

How do I perform Date Comparison in EF query?

Please help. I am trying to figure out how to use DATE or DATETIME for comparison in a linq query. Example: If I wanted all Employee names for those who started before today, I would do something like this in SQL: SELECT EmployeeNameColumn FROM…
Kam
47
votes
9 answers

Why datetime cannot compare?

my C# unit test has the following statement: Assert.AreEqual(logoutTime, log.First().Timestamp); Why it is failed with following information: Assert.AreEqual failed. Expected:<4/28/2010 2:30:37 PM>. Actual:<4/28/2010 2:30:37 PM>. Are they not the…
5YrsLaterDBA
  • 33,370
  • 43
  • 136
  • 210
45
votes
2 answers

Safely comparing local and universal DateTimes

I just noticed what seems like a ridiculous flaw with DateTime comparison. DateTime d = DateTime.Now; DateTime dUtc = d.ToUniversalTime(); d == dUtc; // false d.Equals(dUtc); //false DateTime.Compare(d, dUtc) == 0; // false It appears that all…
jdc0589
  • 6,972
  • 5
  • 36
  • 39
20
votes
3 answers

ZonedDateTime comparison: expected: [Etc/UTC] but was: [UTC]

I was comparing two dates which seem to be equal, but they contain a different name of zones: one is Etc/UTC, another is UTC. According to this question: Is there a difference between the UTC and Etc/UTC time zones? - this two zones are the same.…
Andremoniy
  • 34,031
  • 20
  • 135
  • 241
12
votes
3 answers

php comparing dates for day change

I have found hundreds of questions and answers for topics SIMILAR to this on SO, however, none match my needs specifically and I am stumped. I have a variable in y-m-d format and I need to see if it was created on the previous calendar day (not 24…
MaurerPower
  • 2,046
  • 7
  • 26
  • 48
8
votes
2 answers

Checking if LocalDateTime falls within a time range

I have a time A which should fall within 90 minutes range of timeB (before and after). Example: if timeB is 4:00 pm , time A should be between 2:30pm (-90) to 5:30pm (+90) Tried the following : if(timeA.isAfter(timeB.minusMinutes(90)) ||…
Rk R Bairi
  • 1,289
  • 7
  • 15
  • 39
7
votes
2 answers

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

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 ) <…
7
votes
2 answers

How do I perform date-part comparison in EF

i heard people saying date time comparison do not work just due to time part because datetime has time part. in sql i always compare datetime like this way and it works fine select * from employee where convert(varchar,dob,112) > '20111201' // this…
Thomas
  • 33,544
  • 126
  • 357
  • 626
5
votes
2 answers

How to compare start time and end time in android?

My Question is How to compare two time between startTime and endTime, Comparison two time. Start time End time. I am using the TimePickerDialog for fetching time and I am using one method Which pass the parameter like long for startTime and…
Reena
  • 563
  • 4
  • 11
  • 22
4
votes
2 answers

How to check given time is after 3pm or not in Rails?

I want easiest or simplest method which returns me boolean value (true/false) depending on the given time is after 3 pm or not irrespective of date. for ex:- def after_three_pm(time) //some code here end time= Time.now # Tue Jul 26…
Salil
  • 46,566
  • 21
  • 122
  • 156
4
votes
3 answers

How to make an if statement to show xml attribute based on current time

I have a XML like this: A class like this: public class PrayerTime { public string Fajr { get; set; } public string Sunrise { get; set; } …
Megaoctane
  • 919
  • 3
  • 9
  • 10
3
votes
1 answer

Java8 time comparison in Kotlin

I stumbled across some strange behaviour when comparing Java8 time objects. The below does not appear to be valid code. val t1 = LocalTime.now() val t2 = LocalTime.now() val foo: Int = t1 > t2 Yet hovering over the undersquiggled code shows that…
Vas
  • 2,014
  • 3
  • 22
  • 38
3
votes
2 answers

Time validation using CompareValidator

As a (sorta) follow on from the following question - CustomValidator time c#.net - I would like to know if it is possible to use the CompareValidator to validate a time in a ASP.NET textbox? I have attempted the following
Maxim Gershkovich
  • 45,951
  • 44
  • 147
  • 243
1
2 3 4 5 6 7