Questions tagged [timestampdiff]

56 questions
1
vote
1 answer

Calculating Response Times

In this example, we have a database that has various events, all stored with a uuid. Our goal is to calculate the difference (in minutes) between the initial timestamp of the uuid and the first timestamp of the next record with the same uuid. Right…
Bill Kervaski
  • 542
  • 6
  • 17
1
vote
1 answer

How do I change the TIMESTAMPDIFF date format in MySQL?

I'm using the value of one date table, minus the other date table to create a total time date table. However, I don't like the format. CONCAT( TIMESTAMPDIFF(day,TIME_END,TIME_START), 'd', MOD(TIMESTAMPDIFF(hour,TIME_END,TIME_START),…
1
vote
1 answer

TIMESTAMPDIFF not working if one of the cells is NULL in Python3 MySQL

I have a table with the following four DATETIME columns and the last fifth column INTEGER: time_in1, time_out1, time_in2, time_out2, total_seconds. The function for the "total_seconds" column is…
Endriu Andrei
  • 53
  • 1
  • 5
1
vote
1 answer

Python pandas Calculate difference between 2 timestamp columns in a dataframe excluding weekends in seconds

I have 2 columns with timestamp on them, I need the difference between them in seconds in a 3rd column , excluding weekends. How am I supposed to do this in Python/pandas? I want it to exclude Saturday/Sunday from the timeline. Ex - 1 . Starts at…
1
vote
1 answer

Calculate year difference between 2 dates with 0 year as 1 year

I have 2 dates to compare so I can count years between both date. If days is less than 365 days then I use interval to make it as 1 year. However I have problem if both date is similar in day for example 2019-10-15 to 2020-10-15 will be displayed as…
sg552
  • 1,521
  • 6
  • 32
  • 59
1
vote
1 answer

How to calculate the diffrence between time when the data is DECIMAL?

I'm trying to calculate the time driffrence between two columns, the columns have data: DECIMAL I´ve tried to mix with: TIMESTAMPDIFF(16, CHAR(TIMESTAMP('1997-03-01-00.00.00') - TIMESTAMP('1997-02-01-00.00.00'))) but the data makes it…
The.B
  • 361
  • 2
  • 11
1
vote
2 answers

Mysql 5.6 timestampdiff problem with return result

I have two tables CREATE TABLE `contract` ( `id` int(11) NOT NULL AUTO_INCREMENT, `emp_id` int(11) DEFAULT NULL , `sign_time` datetime DEFAULT NULL , `end_time` datetime DEFAULT NULL , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8…
J. Dr
  • 11
  • 2
1
vote
0 answers

Timestampdiff excluding some hours and weekend mysql

Having two dates (a start and end one), how can I get the difference out in minutes, excluding the hours ranging from 19:00:00 to 08:59:59 and weekends for example? It can not be a duplicate of this, they do not mention any exclusion of the minutes…
Simnme
  • 11
  • 2
1
vote
1 answer

H2 DB - Set time part in timestamp

I'm writing a population script for H2 DB. I have a timestamp, this timestamp always has to be "yesterday", and it's time part has to be at 08:30. I tryed something like DATEADD('DAY', -1, TIMESTAMPADD('MINUTE', TIMESTAMPDIFF('MINUTE',…
Nicolazz92
  • 136
  • 1
  • 12
1
vote
1 answer

timestampdiff returning correct but negative minutes

It's a simple query to retrieve for users, how many minutes, or hours or days they were last online. The calculations for hours and days are correct. However for minutes, the following is returning correct value but negative e.g. -4 minutes, -6…
D. Rattansingh
  • 1,569
  • 3
  • 19
  • 30
0
votes
1 answer

Calculate data dynamically of same row of column with conditions in SQL

I have a table with data of customer with interaction to touchpoint . I need to calculate the time-difference of customer & identify the customer as repeat if the customer is touching the point with in 180 seconds , but if the customer come again…
0
votes
1 answer

Getting NULL values after using timestampdiff and curdate, MySQL

I have table called Client, which has the fields ClientFirstName, ClientLastName, Occupation and ClientDob. I want to get the age of the clients. I will be using the ClientDob field which has a date YEAR datatype. I have done research and tried…
SasuKev
  • 3
  • 2
0
votes
2 answers

Null Results From TIMESTAMPDIFF in DB2 SQL

I am calculating a TIMESTAMPDIFF from timestamps that can have a fairly large range of time intervals between them, from a few tenths of a second to 60+mins. Since the DB2 TIMESTAMPDIFF() function in DB2 returns an integer as a result, I am using…
vann447
  • 3
  • 2
0
votes
1 answer

Calculate TIMESTAMP_DIFF between two columns in BigQuery

I'm very new to SQL and am working with a large dataset (over 300,000 rows of data) and need to calculate the time elapsed between Column A (start time) and Column B (end time) for each row of data. So far, I've been able to figure out how to find…
Jeff Henry
  • 19
  • 4
0
votes
1 answer

Using TIMESTAMPDIFF function on LocalDate in JPA Criteria query

I have to write a query calculating the time difference in years between two dates. One of the dates is fetched from the database whereas the other is a LocalDate. Following is the code I have written: Expression year = new…