Questions tagged [timestampdiff]
56 questions
0
votes
3 answers
VBA String to Date Conversion, and calculate diff from now()
I'm trying below very simple VBA code to convert to Datetime
Sub datetimedifffference()
Dim d As String
Dim sd As Date
d = "2021-04-06T12:56:16+0000"
sd = Format(CDate(d), "mm-dd-yyyy hh:mm:ss")
Debug.Print sd
End Sub
But it is giving type…
0
votes
1 answer
If DOB column is encrypted, how would I go about calculating the age of each person in MySQL
I was given a database where the DOB column is encrypted with crypto. Assuming that the column has to stay encrypted, how would I go about getting/updating the age for each user?
Currently, I calculate the age using the code below :
(userBirthday is…

Michael Lee
- 89
- 1
- 9
0
votes
1 answer
MySQL: selecting one table's row that either has same timestamp or closest+less than the timestamp in another table
I have TableA and Table B as shown below. Currently, as you see in my query below, TableA joins TableB based on box_id and with all rows in TableB whose timestamp is within 1 minute of TableA timestamp.
I would like to modify this query such that…

Mina
- 7
- 3
0
votes
2 answers
MySQL innacurate calculation with average and datetime
I'm having problems with time average calculations. I have a table with a lot of records, the table structure is user id, begin and end time of work (if you want, you can download the table script here) and I need to get the effective working time…

Andino
- 3
- 2
0
votes
1 answer
How to calculate date difference in apache drill sql to get the output in minutes?
I am using dbeaver client connecting to Apache drill hadoop db. Trying to calculate date difference and get the output in minutes.
For Ex: Date 1 is 2015-05-17 22:00:00.000
Date 2 is 2015-05-17 22:45:00.000
Expected Output= 45.
So far I…

Surya
- 51
- 1
- 5
0
votes
1 answer
SQL(DB2) Difference between two dates in hours using Timestampdiff and Cast
If i have two columns with start_date and end_date, how can i find the difference between them using TIMESTAMPDIFF and CAST operator.
Column1 with start_date: 2001-07-11-16.51.40.000000
Column2 with end_date: 2001-07-12-09.21.54.000000
Output: 75301…

kik
- 51
- 2
- 7
0
votes
1 answer
How to find quarter stemp diff by sql please?
I use mysql, and these time columns are not all in the same year.
I use this:
SELECT TIMESTAMPDIFF(QUARTER, DATE_FORMAT('2018-03-30', '%Y-%m-%d'), DATE_FORMAT('2018-09-30', '%Y-%m-%d'))
FROM DUAL;
It returns 2, but this:
SELECT…

xunitc
- 207
- 1
- 2
- 10
0
votes
1 answer
MySQL Calculate Difference between a date and non-consecutive dates
I have this table in mysql, (which at this point will show fake columns and data due to legal matters):
date user_id timestamp
2018-04-27 181 2018-04-27 08:28:33
2018-04-28 181 2018-04-28 03:01:22
2018-05-03 181 2018-05-03…

George C. Serban
- 67
- 1
- 8
0
votes
1 answer
Calculating difference on datetime row betwen rows on the same table
I have table that holds records with tasks, status and time when triggered:
Table tblwork:
+-------------+------------+---------------------+-----+
| task | status | stime | id …

Josef
- 2,648
- 5
- 37
- 73
0
votes
1 answer
MySQL timestampdiff of records on same column
I have a table in which I am trying to sum times on the same column. I have a column where I log all time entries of any event. So, I would like to group them by gateway ID and have the value in hours, minutes and seconds. I have tried to used…

Marcelo Amoretti
- 115
- 7
0
votes
1 answer
Merge two SQL queries together (syntax issue)
I'm using PHP to send this query where lastConn is a datetime object.
$result = $mysqli->query("SELECT id, username, lastConn FROM users LIMIT $startIndex, 50") or die($mysqli->error);
However my goal is not to get the raw lastConn data, but the…

Hal_9100
- 773
- 1
- 7
- 17
0
votes
2 answers
TIMESTAMPDIFF Missing Days
Can someone explain to me why this returns only 360 days and not 365 days?
I expect it to not count the first day but, what about the other 4 days?
SELECT
(TIMESTAMPDIFF(16,CHAR(TIMESTAMP('2017-12-31') - TIMESTAMP('2017-01-01'))))
FROM…

user3183411
- 315
- 2
- 7
- 19
0
votes
2 answers
Group by multiple datediff
I have this table storing when a user last connected to a server:
+----+----------------------------+-----------+
| id | last_connection | something |
+----+----------------------------+-----------+
| 1 | 2017-03-23 10:39:14.000000 |…

Ozh
- 719
- 1
- 7
- 20
0
votes
1 answer
Exclude certain value in column
I want to exclude every 0 in the column "Hoi"
Database
select address, min(from_unixtime(time)) "Aankomsttijd", max(from_unixtime(time)) "Eindtijd",
TIMESTAMPDIFF(MINUTE,min(from_unixtime(time)),max(from_unixtime(time))) "hoi"
from…
user7860868
0
votes
1 answer
Timestamdiff sql doesn't work
I want to make a sql query that shows me those fields and the difference between the time stored in the database and the current clock time is greater than 1 hour (60 minutes).
This is my query but something is not working well, the query shows all…

wiki
- 299
- 4
- 16