Jump to content

Our forum made possible by displaying online advertisements to our visitors.

Please consider supporting us by disabling your ads blocker.

  • Announcements

    • EmperoR

      Dear Guests   12/24/2016

      Welcome to the GIS-AREA. like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be a part of GIS-AREA by signing in or creating an account here. Once you have created your account and have introduced yourself to our community, you can start new topics, reply to others, subscribe interesting threads, get your customize profiles, make news friends, and others nice stuff. To make your stay as pleasant and constructive as possible, please don't forget to read through our pinned forum rules and board guidelines in each section before you do anything else.
Sign in to follow this  
Reyalino

Selecting date on postgresql

Recommended Posts

I have date column on postgresql table with timestamp format i.e "2017-01-01 22:00:00". Does anybody know how to select those date column without put the hour on the queries?

What I type for selecting those date is  "select date from table where date='2017-01-01' " but nothing appear on the result. 

Look forward to hear from you guys !! 

regards

Share this post


Link to post
Share on other sites

Still doesn't work for me.., here is my Table. As alternative I use the query below, but not a simple once in my opinion:

Quote

SELECT* FROM table WHERE date BETWEEN '2017-01-01 00:00:00' AND ' '2017-01-01 23:00:00 '

just in case If I have datetime column on this format "yyyy-mm-dd hh:mm:ss" as timestamp column type.Literally will it works to select the date column by only write query below:

Quote

SELECT*FROM table WHERE date = '2017-01-01'

 

Share this post


Link to post
Share on other sites

in logic, maybe no, your data have  "yyyy-mm-dd hh:mm:ss" format, so you need to query in complete form or maybe using wild card, 

 

Share this post


Link to post
Share on other sites

It works using the query below when I applied into my another table..strange!! :-D

SELECT * FROM table WHERE dt::date = '2017-01-01'

 

surf on the stack and found the query below, and it works. many thanks Lurker

Quote
SELECT date("date_column") FROM my_table
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.