sql-timestamp

Find and sum difference between timestamps in seconds in PostgreSQL using JOOQ

时光怂恿深爱的人放手 提交于 2019-12-11 03:58:51
问题 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 be any TIMETRACKS in the database. In this case the database should return 0 instead. Thats how the TIMETRACKS table looks like: CREATE TABLE "TimeTracks" ( "id" uuid PRIMARY KEY, "startTime" timestamp NOT NULL, "endTime" timestamp, ); This is one

Current moment in H2 database

自作多情 提交于 2019-12-11 01:08:09
问题 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 is executing ? This may be the same or later than CURRENT_TIMESTAMP . For comparison, in Postgres, some functions such as current_timestamp return the transaction start time while some functions such as clock_timestamp return the actual current

How to convert TIMESTAMP values to VARCHAR in T-SQL as SSMS does?

◇◆丶佛笑我妖孽 提交于 2019-12-08 15:09:11
问题 I am trying to convert a TIMESTAMP field in a table to a string so that it can be printed or executed as part of dynamic SQL. SSMS is able to do it, so there must be a built-in method to do it. However, I can't get it to work using T-SQL. The following correctly displays a table result: SELECT TOP 1 RowVersion FROM MyTable It shows 0x00000000288D17AE . However, I need the result to be part of a larger string. DECLARE @res VARCHAR(MAX) = (SELECT TOP 1 'test' + CONVERT(BINARY(8), RowVersion)

Oracle SQL : timestamps in where clause

让人想犯罪 __ 提交于 2019-12-03 04:54:14
问题 I need to look up rows within a particular time frame. select * from TableA where startdate >= '12-01-2012 21:24:00' and startdate <= '12-01-2012 21:25:33' I.e.: I need to look up rows with timestamp precision of SECONDS. How do I achieve this? FYI: The startdate column is of type TIMESTAMP . 回答1: to_timestamp() You need to use to_timestamp() to convert your string to a proper timestamp value: to_timestamp('12-01-2012 21:24:00', 'dd-mm-yyyy hh24:mi:ss') to_date() If your column is of type

How to get time in ISO format with UTC offset from PostgreSQL?

梦想的初衷 提交于 2019-12-01 12:26:47
问题 In python I can get time for different time zones in ISO format like this: >>> import datetime >>> import pytz >>> datetime.datetime.now(tz=pytz.timezone('America/New_York')).isoformat() '2019-03-15T04:01:23.919800-04:00' >>> datetime.datetime.now(tz=pytz.timezone('Asia/Bangkok')).isoformat() '2019-03-15T15:01:23.919800+07:00' Now I need to get timestamps from postgresql in the same format. After some research the best I've come up with is this: postgres=# set time zone 'America/New_York';

Timestamp conversion in Oracle for YYYY-MM-DD HH:MM:SS format

本秂侑毒 提交于 2019-11-30 02:56:16
问题 I'm trying to insert records with YYYY-MM-DD HH:MM:SS format into Oracle from Netezza, but I'm getting invalid date type. How can I accomplish this one? CREATE TABLE AM_PROGRAM_TUNING_EVENT_TMP1 ( ST TIMESTAMP, ET TIMESTAMP, MAS_DIV_KEY INTEGER NOT NULL, SBSC_GUID_KEY INTEGER NOT NULL, STN_KEY INTEGER NOT NULL ); INSERT INTO AM_PROGRAM_TUNING_EVENT_TMP1 VALUES('2012-03-28 11:10:00','2012-03-28 11:30:00',1,3636815,151); 回答1: INSERT INTO AM_PROGRAM_TUNING_EVENT_TMP1 VALUES(TO_DATE('2012-03-28

MySQL 1292 Incorrect datetime value

六眼飞鱼酱① 提交于 2019-11-29 10:09:45
I am getting this error when I try to insert '2011/03/13 02:53:50.000000000' into a timestamp column. If I change the 13 to a 15, 14, 12 or 11 it works no problem. I've also tried changing the /'s to -'s and still no-go. I've looked through some of the other threads related to this error but none seem to apply. I'm running version 5.7.9. It took me a while to figure this out... The problem is that '2011-03-13 02:53:50' is illegal because of daylight saving time switch between 2 and 3 AM, so all time values between 2 and 3 am on any DST introduction day are invalid. Same for '2016-03-13 02:32

MySQL 1292 Incorrect datetime value

六眼飞鱼酱① 提交于 2019-11-28 03:30:00
问题 I am getting this error when I try to insert '2011/03/13 02:53:50.000000000' into a timestamp column. If I change the 13 to a 15, 14, 12 or 11 it works no problem. I've also tried changing the /'s to -'s and still no-go. I've looked through some of the other threads related to this error but none seem to apply. I'm running version 5.7.9. 回答1: It took me a while to figure this out... The problem is that '2011-03-13 02:53:50' is illegal because of daylight saving time switch between 2 and 3 AM,