Questions tagged [date-difference]

Date-difference will give difference in the number of days, months, years etc. between any two calendar dates. (synonyms in stackoverflow.com: datediff, date-diff, date-difference)

446 questions
3
votes
1 answer

Android: Convert 2 different timezones to UTC and calculate their difference in days, hours, and minutes

I have yet to find a straightforward approach to this. I've seen tons of different examples, some actually clash with each other, others are using deprecated calls, I'm not sure why this is so difficult to find a solid answer for. So I have a…
askilondz
  • 3,264
  • 2
  • 28
  • 40
3
votes
1 answer

Android Java : Difference between current time and specific time in future is calculated wrong

I need the difference between current time and specific time in future so that i can pass countdown timer as a parameter. I have function for this operation but it calculates wrong. Here is my function that calculates difference public Date…
itsesc
  • 31
  • 4
3
votes
6 answers

Week difference between 2 dates in C#

I'm trying to make a function in C# that returns the week difference between two dates. Its goal is to provide the same result of: select datediff(ww,'2018-04-13','2018-04-16') as diff In the example above there is only 3 days between these dates,…
André Luiz
  • 6,642
  • 9
  • 55
  • 105
3
votes
1 answer

How to calculate distance between time excluding chunks of time efficiently?

I'm trying to calculate how many minutes are between two dates while excluding periods of time that are arbitrarily defined and occur weekly. I also need to be able to calculate the reverse, where given a time, calculate X number of minutes forward…
Owen
  • 151
  • 1
  • 11
3
votes
2 answers

Momentjs calendar() equivalent for Java

Momentjs has the calendar() function to pretty print timespans like below. For example: "Last Monday at 1:14 PM" "09/21/2017" (if the date is a while ago) Is there an equivalent function in Java (Joda-Time if possible)? moment().subtract(10,…
user2686744
3
votes
2 answers

Finding the real difference between dates in JDK7

How can I find the difference between two dates in JDK7, such that the difference can be added back to make the two dates equal? I tried to use the solution from a similar StackOverflow question, subtracting one date's milliseconds from the other,…
Jay Kelner
  • 45
  • 7
3
votes
2 answers

Number of days between two epoch days in scala

I have two epoch timestamps, I am trying to find the number of days between the two timestamps. This is what I have now: dateFrom = inputEntry.getValue(inputFields(0).get).asInstanceOf[String].toLong dateTo…
d_luffy_de
  • 967
  • 1
  • 9
  • 24
3
votes
1 answer

PostgreSQL - Date difference between two rows in complex query

I've got this query: SELECT apple, banana, update_at FROM ( SELECT DISTINCT ON (apple) * FROM table WHERE apple IN ('ad', 'sa') ORDER BY apple, update_at DESC ) q The purpose of this query is to get the rows that…
RonZ
  • 743
  • 1
  • 11
  • 31
3
votes
1 answer

DateDiff - DST issue

Background I have a scenario where I am calculating the difference between two dates. While the increment differences are spot on, the final calculation has introduced a 60 minute (1 hour) disparity. After investigation and "hair pulling"…
GoldBishop
  • 2,820
  • 4
  • 47
  • 82
3
votes
1 answer

Calculate Year, Month and Day between two Dates in C#

I want exact Year, Month and Day elapsed between two dates. DateTime startDate = new DateTime(1974, 8, 15); DateTime endDate = DateTime.Now.ToLocalTime(); I wish to find Number of Years, Months and Days elapsed between the above two days using…
user6060080
3
votes
1 answer

How to count number of work days and hours extracting public holidays between two dates in SQL

I am new to SQL and stuck in some complex query. What am I trying to achieve? I want to calculate following two types of total days between two timestamp fields. Number of Working Days (Excluding Weekend & Public Holidays) Number of Total Days…
Lokapedia
  • 105
  • 1
  • 4
  • 12
3
votes
1 answer

R - Grouping Dates and Summarizing Data for repeat purchase

I am trying to do analysis on the repeat purchase behavior of the customers. My goal is two-fold: Eliminate all the customer item zip combination that occurs only once (eliminate the non-repeating ones) For the records that repeat, I want to…
ayushku
  • 43
  • 1
  • 5
3
votes
5 answers

calculate time difference between two date in HH:MM:SS javascript

I have created one timer application in javascript. Firstly it takes the current UTC date to init timer with some reference. here's the code on_timer: function(e) { var self = this; if ($(e.target).hasClass("pt_timer_start"))…
BomberMan
  • 1,094
  • 3
  • 13
  • 33
2
votes
3 answers

simple java program that enables 2 Time-format input and count the time-difference

I'd like to know how to make a simple program where user can gave 2 input time(hh:mm) format ---and receive the elapsing time as the output. the program will run and enable user to write time-input.. maybe a simple program that run through command…
2
votes
1 answer

Period between LocalDates produces wrong results

I see that java.time.Period with java.time.LocalDates works mostly as desired and I can use it to get the duration between two dates in years, months and days but I found an example that is not working (not as I expected it), like following: val…
prom85
  • 16,896
  • 17
  • 122
  • 242
1 2
3
29 30