Questions tagged [sql-timestamp]
263 questions
1
vote
1 answer
Add 1 day to timezone aware timestamp with regards to daylight savings
I am trying to add 1 day to a timezone aware timestamp.
In this example I expected + interval '1' day to add 23 hours because DST starts on 2021-03-28 02:00:00 in Europe/Berlin, but it behaves the same as + interval '24' hour:
select timestamp…

Felk
- 7,720
- 2
- 35
- 65
1
vote
1 answer
Select latest N records in BigQuery based on TimeStamp - More Optimized
I want to pick latest 2 records based on the timestamp column, let's say to perform analysis.
In reality i have huge dataset where i want to pick n records for each of my user_n.
If i could hardcode the value, it would have been okay.
SELECT *…

Amar Kumar
- 77
- 6
1
vote
1 answer
PostgreSQL Time Dimension (By Hours and Days) Error
I am am building a Time Dimension table in PostgreSQL with DATE_ID and DATE_DESC.
My T-SQL (works perfectly) script is:
set DATEFIRST 1
;WITH DATES AS (
SELECT CAST('2019-01-01 00:00:00.000' AS datetime) AS [DATE]
UNION ALL
SELECT…

Konstantins Kovalovs
- 25
- 4
1
vote
1 answer
Select row after each condition from the same table myql
I have a table like this:
CREATE TABLE IF NOT EXISTS `logging` (
`id` int(6) unsigned NOT NULL,
`status` varchar(150) NOT NULL,
`timestamp` DATETIME NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
INSERT INTO `logging` (`id`, `status`,…

Dian Arief R
- 69
- 1
- 9
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),…

Tayler
- 13
- 2
1
vote
2 answers
Search data based on timestamp with multiple joins and dependency between timestamp in Postgres
I have two tables prod_replay_in and prod_replay_outas below.
For msg_type as CDST010 in prod_replay_in table has it's confirmation in prod_replay_out table as CDST01C. Same for msg_type as CDST100 has it's confirmation message in prod_replay_out…

Jayveer Parmar
- 500
- 7
- 25
1
vote
1 answer
How to get all the column names whose datatypes are timestamp in MySQL?
In MySQL, I have tables with many columns. How can I get all the column names with the timestamp data type? I want to do it for all the tables in a database.
The data type of timestamp columns can be TIMESTAMP or TIMESTAMP(6).
The output would be…

hbadger19042
- 151
- 1
- 8
1
vote
2 answers
Sqlite query by timestamp and value
I have a Sqlite table with the following rows:
id: int PK autoincrement
timestamp: int value NOT NULL. Timestamp of the DB insertion
value: int value NOT NULL. Possible values [0-4].
I want to query the database to obtain if all the values on the…

qwerty
- 486
- 1
- 11
- 37
1
vote
1 answer
Convert timestamp into datetime and save to replace timestamp
I'm using a SQL Server database and I have a datetime column.
SELECT
[datetime]
FROM [database].[dbo].[data]
datetime
1584538200000
1584538260000
.............
1584538620000
Now I've already known how to convert the timestamp into…

williamfaith
- 247
- 2
- 4
- 9
1
vote
1 answer
Order timestamp durations using AGE function in PostgreSQL
I have a bunch of DVD rental + return times that I'd like to sort by duration, from the shortest rental time (amount of time between timestamps) to the longest rental time. Is AGE the function I should use?
Here's my dysfunctional SQL so far:
…

Splosion Lowbeam
- 73
- 1
- 1
- 10
1
vote
1 answer
SQL - ORDER BY Timestamp Array Data does not work
I have a table with schema as below
fields. TIME_256Hz TIMESTAMP REPEATED
fields. SAC_ACCELX FLOAT REPEATED
fields. SAC_ACCELY FLOAT REPEATED
fields. SAC_ACCELZ FLOAT REPEATED
fields. SAC_GYROX FLOAT REPEATED …

user437777
- 1,423
- 4
- 17
- 28
1
vote
2 answers
PostgreSQL grouping timestamp by day
I have a table x(x_id, ts), where ts is a timestamp.
And I have a second table y(y_id, day, month, year), which is supposed to have its values from x(ts).
(Both x_id and y_id are serial)
For example:
x …

Tomás Gomes
- 45
- 7
1
vote
4 answers
How to make two weeks date_trunk in SQL (Vertica)?
I need to turn each timestamp to its date_trunk with two weeks interval. Say, same as date_trunk('week', event_time), but it would be date_trunk('2 weeks', event_time). So I'd have a timestamp column, and its two-weeks date_trunk column as…

Polly
- 1,057
- 5
- 14
- 23
1
vote
1 answer
Getting Record Creation Date MySql
I have read several posts that relate to this question, but I still can not understand what I am doing wrong. For instance:
Saving timestamp in mysql table using php
and
Display the date of creation of a row in mysql
All I want is to have the date…

5150 Design
- 179
- 14
1
vote
1 answer
Scala, SQL Server - How to insert the current timestamp as datetime in SQL server using Scala?
I want to insert the current timestamp as datetime data type into sql server using Scala.
So far I have tried this:
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
var currentTimeStamp = LocalDateTime.now()
val…

activelearner
- 7,055
- 20
- 53
- 94