By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,471 Members | 711 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,471 IT Pros & Developers. It's quick & easy.

Extract date from timestamp

priyan
P: 54
hi

I am having a startdate variable with timestamp datatype. I want to extract only the date from timestamp field........
Expand|Select|Wrap|Line Numbers
  1. select extract('hour' from timestamp '2001-02-16 20:38:40') 
  2.  
this query extracts hour from the input in the same way is there any option for extracting only date.

Please help as soon as possible.
Aug 8 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 534
Try this:
Expand|Select|Wrap|Line Numbers
  1. postgres=# SELECT date ('2001-02-16 20:38:40');
  2.     date
  3. ------------
  4.  2001-02-16
  5. (1 row)
  6.  
  7. postgres=# SELECT '2001-02-16 20:38:40'::date;
  8.     date
  9. ------------
  10.  2001-02-16
  11. (1 row)
  12.  
Aug 10 '07 #2

priyan
P: 54
Try this:
Expand|Select|Wrap|Line Numbers
  1. postgres=# SELECT date ('2001-02-16 20:38:40');
  2.     date
  3. ------------
  4.  2001-02-16
  5. (1 row)
  6.  
  7. postgres=# SELECT '2001-02-16 20:38:40'::date;
  8.     date
  9. ------------
  10.  2001-02-16
  11. (1 row)
  12.  
thank you for helping me
Aug 11 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.