Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a postgresql query for getting only the date part of timestamp field, from a table

Tags:

sql

postgresql

How to write a postgresql query for getting only the date part of timestamp field, from a table

like image 349
Linto davis Avatar asked Mar 01 '10 09:03

Linto davis


People also ask

How do I get just the date from a timestamp?

You can use date(t_stamp) to get only the date part from a timestamp. Extracts the date part of the date or datetime expression expr.

How do I query a timestamp column in PostgreSQL?

PostgreSQL timestamp example First, create a table that consists of both timestamp the timestamptz columns. Next, set the time zone of the database server to America/Los_Angeles . After that, query data from the timestamp and timestamptz columns. The query returns the same timestamp values as the inserted values.

How do I select a date from a timestamp in SQL?

In MySQL, use the DATE() function to retrieve the date from a datetime or timestamp value. This function takes only one argument – either an expression which returns a date/datetime/ timestamp value or the name of a timestamp/datetime column. (In our example, we use a column of the timestamp data type.)


1 Answers

select DATE(my_field) from my_table; 
like image 137
Konrad Garus Avatar answered Sep 24 '22 12:09

Konrad Garus