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
7
votes
4 answers

Joda-time off-by-one error when counting days after 1918-03-24

Calculating the number of days between 1900-01-01 and a date after 1918-03-24 using Joda-Time seems to give an off-by-one result. Using Java 8 java.time gives the correct result. What is the reason for Joda-Time not counting 1918-03-25? Using…
Chro
  • 1,003
  • 2
  • 15
  • 27
6
votes
1 answer

How to find difference between two dates in years months and days in Java?

Suppose I have : Employee model which has startDate as its property variable and Promotion model has promotionDate. I want to find out for how long employee has worked until his promotion for which I have to find difference between promotionDate…
rizius
  • 61
  • 1
  • 4
6
votes
2 answers

Calculating number of months between two OffsetDateTimes

I am using java 8 and I'm trying to calculate the amount of months between two OffsetDateTime objects. What is the best way to do this?
Nevo Mashiach
  • 79
  • 1
  • 4
6
votes
2 answers

Python difference in years between a datetime.now() and a Series filled up with dates?

I would like to create a new column in my dataset, which is a difference in years between today and a another column already in the dataset, filled up with dates. the code above: df['diff_years'] = datetime.today() -…
Wagner R.
  • 63
  • 1
  • 4
6
votes
2 answers

R Converting from datetime to date

I have to do a difference between dates and return the number of days. the format of the dates is as follows: 12/9/2011 12:00:00 AM Does anyone know how to perform the difference without using lubridate?
Dario Federici
  • 1,228
  • 2
  • 18
  • 40
6
votes
6 answers

SQL DateDiff without weekends and public holidays

I am looking for solution how to select number of days between two dates without weekends and public holidays. So far I have this: SELECT evnt.event_id, evnt.date_from, evnt.date_to, DATEDIFF(DD, evnt.date_from, evnt.date_to) …
Kajiyama
  • 3,393
  • 8
  • 26
  • 38
6
votes
1 answer

Pandas groupby: Count the number of occurrences within a time range for each group

I have a dataframe: ID DATE WIN A 2015/6/5 Yes A 2015/6/7 Yes A 2015/6/7 Yes A 2015/6/7 Yes B 2015/6/8 No B 2015/8/7 Yes C 2015/5/15 Yes C 2015/5/30 No C 2015/7/30 No C 2015/8/03 Yes I want to add a column…
ChiefsCreation
  • 389
  • 1
  • 3
  • 10
5
votes
2 answers

Comparing two date objects of different TimeZones and get the exact time difference in seconds

I am trying to compare received date of an email(date object) with a date(String) in a JSONObject. The two dates are going to be of different Timezones with a difference of 1 hour. My scenario is that I'll have to get the exact difference between…
Hemanth Annavarapu
  • 823
  • 3
  • 19
  • 37
5
votes
5 answers

Get date difference in year, month, and days SQL

Is there a way to calculate how old someone is based on today's date and their birthday then display it in following manners: If a user is less than (<) 1 year old THEN show their age in MM & days. Example: 10 months & 2 days old If a user is…
NonProgrammer
  • 1,337
  • 2
  • 23
  • 53
4
votes
2 answers

Power Query filter date from today minus ? days to today

I'm just learning Power Query and trying to figure out how modify a filter to return data within a dynamic date range. E.g. from Today - 60 days to Today Here's the code, any help much appreciated. = Table.SelectRows(#"Changed Type", each [Start] >=…
Kholt69
  • 43
  • 1
  • 1
  • 4
4
votes
2 answers

Remove the first row from each group if the second row meets a condition

Here's a sample of my dataset: df=data.frame(id=c("9","9","9","5","5","5","4","4","4","4","4","20","20"), Date=c("11/29/2018","11/29/2018","11/29/2018","5/25/2018","2/13/2019","2/13/2019","6/7/2018", …
hk2
  • 487
  • 3
  • 15
4
votes
2 answers

SQL Server LAG() function to calculate differences between rows

I'm new in SQL Server and I've got some doubts about the lag() function. I have to calculate the average distance (in days) between two user's activities. Then, I have to GROUP BY all the users, calculate all the date differences between rows for…
user9863243
4
votes
2 answers

Get the time difference between the first and last row

My table structure is like this id date Time userid 17 2017-01-22 05:08:09.0000000 836232017 16 2017-01-22 05:08:05.0000000 836232017 11 2017-01-22 05:06:40.0000000 836232017 10 2017-01-22 05:06:38.0000000 …
Deepu T
  • 724
  • 7
  • 20
4
votes
6 answers

PHP Get days difference between a date and the date today (Now)

I can't seem to get this to work. I have tried from the samples online but there wasn't one the is exactly what I needed. Basically I want to be able to display the number of days that passed from the given date. My sample below is a combined HTML…
Jin Pards
  • 189
  • 1
  • 2
  • 13
4
votes
5 answers

Get Date of Previous Monday

I'm trying to get the date of the monday in the current week. Is this close to correct? Dim MondayOfCurrentWeek As Date = Date.Today - Date.Today.DayOfWeek + 1 As far as I understand it the AyOfWeek indexes are: 1 = Monday 2 = Tuesday 3 =…
user1283776
  • 19,640
  • 49
  • 136
  • 276
1
2
3
29 30