Prisma: Create timestamp field without date

1.9k views Asked by At

I want to create a field in my table in a timestamp type but without a date stamp. The DateTime type generates that WITH a date stamp but i dont want that. Can anyone help me?

Thanks in advance! :)

1

There are 1 answers

2
Adrian Klaver On

Use a time field time(stamp) types:

select '2020-09-28 12:22'::timestamp::time;
time   
----------
 12:22:00

\d ts_test 
                         Table "public.ts_test"
  Column  |            Type             | Collation | Nullable | Default 
----------+-----------------------------+-----------+----------+---------
 ts_tz    | timestamp with time zone    |           |          | 
 ts       | timestamp without time zone |           |          | 
 ts_txt   | character varying           |           |          | 
 time_fld | time without time zone      |           |          | 

insert into  ts_test (time_fld) values ('2020-09-28 12:22');

select * from ts_test where time_fld is not null;
 ts_tz |  ts  | ts_txt | time_fld 
-------+------+--------+----------
 NULL  | NULL | NULL   | 12:22:00

The timestamp will be truncated to a time.