Questions tagged [sql-timestamp]

263 questions
1
vote
2 answers

Delete redundant timestamp ranges in Postgres SQL

I have a table which is having filenames and a number of timestamp ranges for each file for eg as below: filename mindatetime maxdatetime monitor_4.dat 2019-04-28 09:00:00 AM 2019-04-29 11:00:00 AM …
Abhilash
  • 803
  • 1
  • 9
  • 32
1
vote
1 answer

Applying unique constraint of date on TIMESTAMP column in postgresql

I have a postgresql table as CREATE TABLE IF NOT EXISTS table_name ( expiry_date DATE NOT NULL, created_at TIMESTAMP with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP(0), CONSTRAINT user_review_uniq_key UNIQUE (expiry_date,…
Alok
  • 7,734
  • 8
  • 55
  • 100
1
vote
1 answer

Getting incorrect date when converting epoch to timestamp

I have a timestamp in epoch format like this: 1551187548876. If I convert this to a timestamp using https://www.epochconverter.com/, I get the correct time back. However, if I convert it to time using PostgreSQL to_timestamp, I get the…
Anthony
  • 33,838
  • 42
  • 169
  • 278
1
vote
1 answer

Inserting current_timestamp at time zone GMT gives local time instead

I got a PostgreSQL database in which I have a date field in the invoices table: Column | Type | payment_date | timestamp with time zone | The server is located at GMT-5, as you can see: $date Tue Jan 22 17:33:01…
1
vote
1 answer

difference between 2 timestamp data with nanoseconds in hive

I have 2 columns with timestamp data upto nanoseconds which is coming from a transaction log file. I want to find the difference in time upto nanoseconds. I have tried to directly subtract the columns data by converting them into timestamp but…
1
vote
1 answer

String to Timestamp conversion difference error in Java

I have the following value: 2018-01-16-18.56.57.300000 It is passed to the method parameter: "value". private Timestamp getPossibleTimestampI(String value) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh.mm.ss.SSS"); …
Oliver
  • 1,218
  • 1
  • 17
  • 21
1
vote
1 answer

creating max date function using sql in databricks

I am writing queries in databricks using sql on views and would like to calculate max of dates of update timestamp column across multiple views. for instance i am joining table a with table b and would like to know max(a.updt_ts,b.updt_ts). since…
codewalker
  • 67
  • 1
  • 6
1
vote
1 answer

MySQL: Multiple Timestamps in One Table for DateAdded, DateUpdated

I want to have multiple Timestamps in one table for columns DateAdded and DateUpdated. I have this incorrect definition where DateAdded is at '0000-00-00 00:00:00' and only works for DateUpdated. `DateAdded` timestamp NOT NULL DEFAULT '0000-00-00…
Vad
  • 3,658
  • 8
  • 46
  • 81
1
vote
1 answer

java.sql.Timestamp to Date Conversion in Oracle SQL

I have run into this weird Timestamp to Date Conversion issue in Oracle SQL. Here is the SQL statement: String INSERT_SQL = String.format("INSERT INTO AUDIT_TASK (%s, %s, %s, %s) VALUES…
rightCoder
  • 281
  • 1
  • 3
  • 18
1
vote
2 answers

Laravel: Change the timestamps' names in the database

I'm trying to rename the timestamps columns (created_at and updated_at) of the user table in my database. I have already seen this answer but when I override the CREATED_AT and UPDATED_AD constants like that: class User extends Authenticatable { …
JacopoStanchi
  • 1,962
  • 5
  • 33
  • 61
1
vote
1 answer

Flink SQL - How to parse a TIMESTAMP with custom pattern?

From documentation it looks like Flink's SQL can only parse timestamps in a certain format, namely: TIMESTAMP string: Parses a timestamp string in the form "yy-mm-dd hh:mm:ss.fff" to a SQL timestamp. Is there any way to pass in a custom…
1
vote
1 answer

Oracle SQL: Count between irregular timestamps

I'm sorry if this question has been asked here before, but I can't seem to find it. I keep finding how to sum per hour, but my question is regarding SUM and COUNT between timestamps that are defined in another column. I have one table called…
Ronald
  • 172
  • 2
  • 11
1
vote
2 answers

SQL Sort data into age bins based on date of birth and timestamp of datapoint

I'm new to sql, and stackoverflow, so please show me mercy. I have 3 tables (described below). I have searched a lot for this specific problem and have not found a solution. I'm a graduate student studying the behavior and psychology of kids as they…
smlee87
  • 21
  • 2
1
vote
3 answers

Sum multiple times produced in a query (timediff)

I have two fields: Initial (timestamp) Final (timestamp) My query is: SELECT TIMEDIFF(Final, Initial) AS 'Worked Hours' FROM `db_foo` WHERE matriculation='X' AND date='2017-yy-yy' The result will be something like Worked Hours …
flapane
  • 543
  • 2
  • 8
  • 21
1
vote
2 answers

Issues with TIMESTAMP and CURRENT_TIMESTAMP in SQL commands

I have some issue creating tables that use CURRENT_TIMESTAMP to specify a date. I need this because I'm using java jpa entities to retrieve them by date. If I run to a local h2 database I have no issues. In this example: INSERT INTO Post (id, title,…
MrSir
  • 576
  • 2
  • 11
  • 29