Questions tagged [sql-timestamp]
263 questions
5
votes
2 answers
How to compare java.sql.Timestamp and java.util.Date
I know java Date was poor designed, but I don't know how until today.
I saved a date to DB and when I get it from DB and compare to original date, it told me it's different!
And I wrote a test which looks strange but it PASSED!
@Test
public void…

Eric
- 655
- 2
- 9
- 16
5
votes
1 answer
How to insert a PostgreSQL timestamp datatype into a timestamp array
I have a table containing a array of timestamps, like the following:
CREATE TABLE start_times
(
start_date timestamp[]
);
I am not sure how to insert the timestamp values into the array. I read in a article that I should use double quotes, instead…

user3439729
- 79
- 1
- 1
- 3
4
votes
3 answers
Find and sum difference between timestamps in seconds in PostgreSQL using JOOQ
This is a follow up question to another question of mine (Find difference between timestamps in seconds in PostgreSQL using JOOQ).
I want to to sum the diff of TIMETRACKS.ENDTIME and TIMETRACKS.STARTTIME in seconds. It can happen that there will not…

Tobias Marschall
- 2,355
- 3
- 22
- 40
4
votes
3 answers
What difference between
I have first query
select count(*)
from `order`
where marketer_id = 75 and
HandleStatus != -1 and
(Created_at BETWEEN '2017-05-01' AND '2017-05-31')
and result is 1050
i also have second query :
select count(*)
from `order`
where…

Hoang Nam
- 101
- 1
- 10
4
votes
1 answer
java.sql.Timestamp to Joda Instant and vice versa
Is this possible? I found a few solution for converting to and from localDateTime like can be seen here
But I can't find a solution for Joda Instant...

JTK
- 1,469
- 2
- 22
- 39
3
votes
0 answers
how to check timestamp of the high value for the table partitions in oracle sql
the high value for one of my table partition in oracle sql is TIMESTAMP' 2022-09-06 00:00:00'. My understanding is that it does not represent any timezone. Is there a way for me to check what timezone is it referring to? Thanks.

jiii
- 71
- 4
3
votes
2 answers
Cockroachdb format datetime in select query
I'm trying to format a timestamp value to yyyymmdd in cockroach DB select query.
In MySQL, we can format a date using DATE_FORMAT()
E.g. SELECT DATE_FORMAT(created_at, "%Y-%m-%d") FROM users to fetch result into a desired format.
What would be an…

Hashmat
- 149
- 1
- 11
3
votes
3 answers
ERROR: invalid value for "MI" Detail: Value must be an integer
In PostgreSQL, I got an error for the following request:
SELECT TO_TIMESTAMP('2020-03-07T22:34:18Z', 'YYYY-MM-DDTHH24:MI:SSZ');
which yielded:
ERROR: invalid value ":1" for "MI" Detail: Value must be an integer.
Why there would be an error…

manuch100
- 181
- 2
- 15
3
votes
1 answer
PostgreSQL extract function in respect to timezones
I use the PostgreSQL extract function to pull out month, quarter, year like this:
select extract (month from adate) from atable
adate is a timestamp with time zone.
The problem I have is that I find this function completely ambivalent of timezone…

springcorn
- 611
- 2
- 15
- 28
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
3
votes
1 answer
MySQL incorrect timestamp value
I'm trying to insert datetime value '1970-01-01 00:00:01' in timestamp column but MySQL returned an error "Incorrect datetime value: '1970-01-01 00:00:01' for column 'timestamp'"
CREATE TABLE TST_TABLE
(
tst_column timestamp NULL
)
INSERT INTO…

Denis
- 129
- 1
- 4
- 12
3
votes
1 answer
PostgreSQL - Date difference between two rows in complex query
I've got this query:
SELECT apple, banana, update_at FROM
(
SELECT DISTINCT ON (apple) *
FROM table
WHERE apple IN ('ad', 'sa')
ORDER BY apple, update_at DESC
) q
The purpose of this query is to get the rows that…

RonZ
- 743
- 1
- 11
- 31
3
votes
1 answer
SQL, convert integer for Timestamp subtraction
Assume we have a relation R(A, B), with
A contains int values and B contains Timestamps.
We have to calculate: (time in B in minutes) - (int to minutes).
Example:
(125, "2017-06-01 16:23:00")
16:23:00 = 983 min
125 = 125min
983 - 125 = 858min
The…

normalUser221
- 41
- 7
3
votes
4 answers
How to check if a set rows is covering the whole time range
I have a table in which there are two columns StartTime and EndTime. Values are filled in it as:
declare @tbl Table(
colA VARCHAR(50),
colS VARCHAR(50),
DATES DATE,
STARTTIME TIME,
ENDTIME TIME,
ID BIGINT NOT NULL IDENTITY(1,1)
)
INSERT INTO…

Hemant Sisodia
- 488
- 6
- 23
3
votes
1 answer
Current moment in H2 database
How to get the actual current clock time, the current moment, in H2 database?
The CURRENT_TIMESTAMP function gives the moment when the current database transaction began. Is there a way to get the current moment, the time when the current statement…

Basil Bourque
- 303,325
- 100
- 852
- 1,154