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)
Questions tagged [date-difference]
446 questions
2
votes
0 answers
SQL Query - Identifying entries between payment dates greater than 6 years
I have this table (in reality it has more fields but for simplicity, it will demonstrate what I'm after)
Payment_Type
Person…

Craigofdoom
- 21
- 2
2
votes
3 answers
How to put output, MsgBox Result on new column
I am tracking payments made on a large excel file. In column C, I have the date we received the payment, in column I, I have the date paid. I'd like to calculate how many months between column C (when we rcvd invc) and column I (when invc was…

Vee
- 21
- 2
2
votes
2 answers
Join Hours and Minute column for showing in Decimal format SQL Query
I have two datetime columns in a SQL Server table:
+--------------------------+------------------------+
| CompLast_SignON_datetime | comp_accidentdate_time |
+--------------------------+------------------------+
| 16-12-2021 04:08 |…

user1185088
- 99
- 1
- 1
- 8
2
votes
1 answer
I am trying to return just the amount of days between deadline and launch date. However it is returning the hours minutes and seconds as well
Here is the code I have so far:
import pandas as pd
df = pd.read_csv('/content/drive/MyDrive/Colab Datasets/KickstarterRevised.csv')
df['deadline'] = pd.to_datetime(df['deadline'])
df['launched'] = pd.to_datetime(df['launched'])
df['difference']…

Bryan Lucky-Heard
- 23
- 2
2
votes
2 answers
Date Difference Calculation in Java by excluding weekends
Am very beginner and new to Java platform. I have the below 3 simple Java date difference calculation functions. I wanted to exclude weekends on the below calculations in all the 3 methods. Can anyone please help how to exclude weekends for the…

Sheila
- 21
- 5
2
votes
1 answer
Number of days in leap years with IsoChronology
2000 CE is a leap year with 366 days.
2001 CE and 2002 CE do not leap years and have 355 days.
Logically, if I ask the number of days between January 1st, 2000 CE and January 1st, 2001 CE, I should get one more day than between January 1st, 2001 CE…

Gzorg
- 809
- 4
- 10
- 25
2
votes
2 answers
Difference current month / month a year back on customer level in Power BI
I am trying to calculate the sales volume difference between a given month and the same month one year back (e.g Jan 2021 - Jan 2020). The tricky part is that it should be done on customer level. My table now looks like…

krasi
- 33
- 4
2
votes
1 answer
date diff function in query of google sheets
I got the below result using the formula
={query(SALES!A2:Y ,"Select B, C, D, G, P, Sum(T), datediff(now(), todate(P)) WHERE O ='"&(A1)&"' GROUP BY B, C, D, G, P ORDER BY datediff(now(), todate(P)) DESC Label Sum(T) 'PENDING AMOUNT',…

Narahari GL
- 21
- 2
2
votes
3 answers
Oracle sql: filtering repeated rows that only differ by a tiny amount of time
I have an Oracle table with event alarms, and due to a weird and unknown -to me- condition alarms get repeated sometimes so I was asked to create a service that will remove repeated alarms from that Oracle table.
The condition to consider an alarm…

Diego Perez
- 2,188
- 2
- 30
- 58
2
votes
2 answers
Creating an array of the difference between items in another array
My goal is to create an array on integers, each representing the days elapsed between two dates. Eventually I’ll average and do other operations on it.
I’ve reached working code:
require 'date'
dates = ['2020-01-30', '2020-01-24', '2020-01-16'].map…

user137369
- 5,219
- 5
- 31
- 54
2
votes
1 answer
Presto: Time difference in minutes between two timestamps only for working hours
I am trying to find the time difference in minutes between two dates, but I want the difference to account for the time the shop was open. The shop is open only 9 hours a day and only on weekdays (weekends are closed too), thus the time difference…

Bruce Wayne
- 471
- 5
- 18
2
votes
3 answers
How do I get a number of days left if the number of days includes the days of another year?
I am trying to implement something that can countdown how many days left before an event occurs. While dealing with days within the same year is fine. But now I am having a problem with showing a number of days which includes days that are not in…

Suri
- 693
- 7
- 16
2
votes
4 answers
Nearest neighbor distance for k=1 in units of time
I have the following dataframe
A_key Date
A1 2016-05-03
A1 2016-09-25
A2 2015-02-25
A2 2015-02-25
A3 2015-10-04
A3 2016-03-15
A3 2016-04-10
A4 2015-09-26
…

iprof0214
- 701
- 2
- 6
- 19
2
votes
3 answers
SQL Server 2012 : DATEDIFF function in terms of years, days and months
I am using the DATEDIFF function in SQL Server 2012. I have two dates, 2015-01-01 and current_date. I need DATEDIFF in terms of Years , Months & Days between these two dates. below are my statements :
SELECT DATEDIFF(YY, '2015-01-01', GETDATE()) AS…

Sumeet Kumar
- 321
- 4
- 17
2
votes
1 answer
How to subtract dates on different rows in POWER BI
I have a table that looks like this:
Bear with me this is going to get a little confusing;
I want to get the values in the desired column. The calculation is:
StartTime-(previous row)Endtime. So row 2 (Starttime) minus row 1 Endtime would be…

dragonfury2
- 375
- 5
- 20