473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Extract date from timestamp

priyan
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
2 32913
michaelb
534 Expert 512MB
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
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

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

Similar topics

2
by: Ben | last post by:
I would like to use php to query a database and retrieve a unix timestamp. The problem is that mysql is storing the data in the date format and not a timestamp. I am sure that I can amend my...
13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
2
by: zaceti | last post by:
I'm new to MySQL and I am having a problem selecting the highest valued date/time for a particular day. Here is the table structure: ...
6
by: bryan.seaton | last post by:
I have a delete statement that is not doing what I want it to do: Delete from LOG_TABLE where (DATE(LOG_TS)) < (DATE(CURRENT_DATE)- 21 DAYS); It is supposed to delete all records that are 21...
2
by: Russell Smith | last post by:
Timestamps support infinity. However if appears dates do not. When timestamps are cast to dates, there is no output. Is this an acceptable option or not? Below are a number of examples...
5
by: rs | last post by:
I have a table with a timestamp field which contains the date and time. ie. 9/13/2004 9:10:00 AM. I would like to split this field into 2 fields, one with just the DATE portion ie 9/13/2004 and...
2
by: johndcal | last post by:
Hello All, I have a date value that I pull from a .csv file. After reading the file and storing the values in an array the value of the date could be found in $array, for example....
6
by: Kentor | last post by:
does anyone know of a script that would produce a calendar starting from todays date with checkboxes next to every day of the month so that the user is able to check it in case of an event for that...
3
by: backups2007 | last post by:
what code should I use to extract and date in a timestamp? please help. thanks in advance.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.