Questions tagged [sql-timestamp]

263 questions
2
votes
2 answers

Trying to read mm/dd/yyyy format in sql while creating table

So I am very new in SQL and I am trying to create a table where I will later import a .csv file. In this table there is a time stamp column that I want to set it up to read mm/dd/yyyy hh:mi:ss, yet I've tried doing this: create table…
user665997
  • 313
  • 1
  • 4
  • 18
2
votes
1 answer

jOOQ fetched timestamp has no nanoseconds

In a postgres db, using jOOQ, when I fetch a row that has a column defined as timestamp without time zone when I do a select and I get the value (fetched by jOOQ into a java.sql.Timestamp), then I see that the nanoseconds are missing. E.g., in the…
mat_boy
  • 12,998
  • 22
  • 72
  • 116
2
votes
3 answers

How can I avoid a timestamp insert error when copying data from one table to another?

I'm trying to cull the data in a list of tables (~30) based on a primary key. My approach has been to: 1.Create an intermediate table & load it with the desired data for each table 2.Truncate the original table 3.Insert the data from the…
Rolan
  • 2,924
  • 7
  • 34
  • 46
1
vote
3 answers

How to get min and max from a timeseries data in SQL/Snowflake?

my data is something like this, timestamp is ordered in asc. INSERT INTO timeseries (timestamp, value) VALUES ('2022-01-01 00:00:00', 0.89), **('2022-01-01 10:01:00', 6.89), ('2022-01-02 10:01:21', 10.99), ('2022-01-02 10:07:00', 11.89),** …
1
vote
3 answers

How to convert VARCHAR (AM/PM) to TIMESTAMP (24 h) in SQL (Teradata v17)

I've tried multiple solutions, but I keep getting errors. I need to create a new column casting VARCHAR to TIMESTAMP that includes AM, PM or -ideally- changes it to 24 hrs format. VARCHAR format (Start_Date column): 8/3/2022 4:58:49 PM I found the…
Aurora
  • 11
  • 2
1
vote
1 answer

How to Convert Array or String in Snowflake to Timestamp_NTZ

I currently have some incoming datestamps as from outside datasource, but am struggling to define them in a table through my Snowflake Tables. The column is formatted as such:…
1
vote
1 answer

Query runs fine in SQL Developer but gives Error Msg = ORA-00905: missing keyword in JDBC

I am trying to run this SQL prepared statement from code. select COUNT(*) from table1 ed, table2 e where ed.id = e.id and e.status_cd = ? and ed.active_ind = 1 and {in} and systimestamp < FROM_TZ(cast(ed.end_effective_dt_tm as…
allocated
  • 1,295
  • 3
  • 13
  • 16
1
vote
1 answer

How to set a date for future in mysql

I am creating a table that has 3 columns one primary key id the other one reg_date to hold the date that the user has registered and the last one exp_date which is 4 years ahead of reg_date to hold the expiry date of the account. How can I set the…
1
vote
1 answer

Postgres indexing for timestamp range does not work

I have a following table with 1.000.000 rows create table event ( id serial constraint event_pk primary key, type text not null, start_date timestamp not null, end_date timestamp not null, …
1
vote
2 answers

how to write a query in snowflake for timestamp difference between two date_time fields. The format should be in DD:HH:MI:SS?

I have a sql query on teradata for difference between to timestamp fields TO_CHAR(MAX(BE.E_END_DATETIME_PST)-MIN(BE.E_START_DATETIME_PST),'DD:HH:MI:SS') END AS "TIME_BTWN_CASE_START&END" example: (1/16/2021 09:56:05.882000)-(1/1/2021…
1
vote
1 answer

Why time format is changing in Azure Databricks

I have a file with a timestamp with time format as 2017-01-20 16:53:05.212 (yyyy-MM-dd HH:mm:ss.SSS). I have uploaded this file to Azure data lake gen 2 and accessed that file into Azure Databricks. But when I have executed the below simple query in…
sai m
  • 99
  • 1
  • 15
1
vote
0 answers

how to decipher this 8 digit timestamp?

I am retrieving data of certain events from an API. And I came across this super strange 8 digit number (some sort of timestamp most probably) but I can not make any sense of what those numbers are. The API documentation wasn't kind enough to tell…
Hammad
  • 529
  • 7
  • 17
1
vote
1 answer

Reading and Writing UTC to TIMESTAMP in Postgresql

I have a Java application that inserts data into a database using prepared statements. In the preparedStamement date is set in UTC format. preparedStatement.setDate(index, new java.sql.Date(date.getTime()), UTC); I want to be sure that when read…
yed2393
  • 262
  • 1
  • 12
1
vote
1 answer

Postgres - convert international atomic time to UTC time (for loop with IF inside SQL function body)

I need to store TAI time in a pg database. This requires a custom type, CREATE TYPE tai AS ( secs int, nanosecs, int ); which maps 1:1 to a GNU C timespec struct, with the TAI epoch of Jan 1 1958 00:00:00 and monotonic clock at its…
Brandon Dube
  • 428
  • 1
  • 10
  • 26
1
vote
0 answers

Numeric Timestamp date diff calculation

I tried calculating in Pycharm sql the diff between two different columns of start timestamp end timestamp I tried using TIMESTAMPDIFF func but sql doesn't recognize the different date segments 'second' 'minute' etc. any ideas?
Guy.b
  • 11
  • 1