Questions tagged [timestampdiff]

56 questions
5
votes
2 answers

Convert string to Timestamp in Javascript using MomentJS

I have a string like : var from = '2016-06-06T21:03:55' ; Now how do I convert it into a timestamp such that I can give it as an input to momentjs. Basically, I want to find the difference in the timestamps as seen in this post : Get hours…
learntogrow-growtolearn
  • 1,190
  • 5
  • 13
  • 37
3
votes
1 answer

Find difference between timestamps in seconds in PostgreSQL using JOOQ

I need to find the difference between two timestamps in seconds using JOOQ. I have taken a look at some answers on StackOverflow using raw SQL, however i didn´t find a way to implement it using JOOQ. Here are some solutions that i found that are…
Tobias Marschall
  • 2,355
  • 3
  • 22
  • 40
2
votes
2 answers

How to fix case statement with timestampdiff error 1064

I am using MySQL 8 and am trying to get the time difference between the current time and a field in my database table called "created_on". If the difference is less than 180 seconds, I need the query to return the number of seconds. If the number…
wilcan
  • 53
  • 7
2
votes
4 answers

How to perform SQL without duplicate calculation

I have following code: SELECT * FROM tier WHERE TIMESTAMPDIFF( HOUR, now(), FROM_UNIXTIME(expireAt) ) < 72 AND TIMESTAMPDIFF( HOUR, now(), FROM_UNIXTIME(expireAt) ) > 0 You can see, that there is a TIMESTAMPDIFF calculation twice. Is…
vimov32802
  • 89
  • 2
  • 5
2
votes
1 answer

MYSQL difference between two datetime

I have the following table. table1: id_user | action | time --------+--------+---------------------- 1 | 2 | '2009-05-18 11:45:42' 1 | 2 | '2009-05-18 11:45:45' 1 | 3 | '2009-05-18 11:45:50' 1 | 2 |…
2
votes
2 answers

mariadb/mysql NOW() and TIMESTAMPDIFF behavior - is it by design?

Just porting some code from OracleDB into MariaDB and been converting some OracleDB expressions (like SYSDATE - ? / 1440) to MariaDB notation (this seems to fit fine: NOW() - interval 60 * ? second). Stumbled upon what I suspect to be either a…
Vlad
  • 1,157
  • 8
  • 15
2
votes
2 answers

MYSQL TIMESTAMPDIFF function is not working

I am trying to use TIMESTAMPDIFF function in one of my queries and is making an headache for me. TABLE id | web_address | timeperiod | timeperiod_exp 1 | www.google.com | 1564692614 | 1564779014 1564692614 = GMT: Thursday, August 1,…
MR_AMDEV
  • 1,712
  • 2
  • 21
  • 38
2
votes
1 answer

How to compensate MySQL TIMESTAMPDIFF for overflow

I am using the MySQL TIMESTAMPDIFF() function to calculate the difference in months between two dates, but there is a problem with overflow. Say I have a date, and I use MySQL to calculate the same date 1 month later: select DATE_ADD('2018-10-31',…
roelvanmeer
  • 356
  • 4
  • 18
2
votes
1 answer

MYSQL: combine year() and timestampdiff()

Is it possible to combine the functions year() and timestampdiff()? I have columns with persons, date of birth (dob) and dates of events, and I would like to know the age the person has at the first of July (01-07) in the year the event took…
Bingley
  • 21
  • 1
  • 4
2
votes
3 answers

Why do I get a NULL for this timestampdiff()?

Why does the following query in MySQL result in a null for that timestampdiff()? SELECT EndDate, /* EndDate is YEAR(4) datatype with value 2013 */ year('2015-01-01') a, timestampdiff( YEAR, Year('2015-01-01'), EndDate) b FROM…
Johnny Rollerfeet
  • 116
  • 1
  • 3
  • 12
2
votes
3 answers

Mysql Calculate minutes between previous end time and current start for system downtime records

I need help, I need to calculate the difference in minutes between the previous end date and the start date of a current incident, According to a system row. this is the table: id |system |start |end …
1
vote
1 answer

JOOQ timestampDiff(field_datetime1, field_datetime2) to set value in an update query not working

I'm using MYSQL and JOOQ and I'm trying to write an update query. In this query I want to update field_datetime1 (type datetime) and also update field_timedifference (type bigint) with the time difference in milliseconds between field_datetime1 and…
1
vote
0 answers

MySql TIMESTAMPDIFF with float value

hoping you all are doing well, I'm working with MySql and using a TIMESTAMPDIFF function like this: TIMESTAMPDIFF(HOUR, 07:00:00, 16:30:00) and this return 9 So my question is, there's a way to get the return as 9.5 (nine and a half…
1
vote
1 answer

Why are we using two mods for timestamp_diff of seconds in time

As a part of a course, I have been trying to analyze a dataset of fitness device which has timestamps. I'm trying to take a difference of time in order to calculate no. of hours a user is sleeping. And for that I came across this code - SELECT …
1
vote
0 answers

How can i store the return value from the timestampdiff function

I am using the below query to find the time difference in minutes. SELECT timestampdiff(minute,created_at,now()) AS TIMEDIFF Below is the TIMEDIFF in minutes using the above query id TIMEDIFF 193996 175 193997 46 But when I try to…
Aarthy
  • 11
  • 2
1
2 3 4