Thursday, October 18, 2012

to_char() and to_date() functions in SQL



Very common usage especially while dealing with Date/Time columns while querying from database.

To update a specific date column with a specific Date and Time,


update employee set hire_date= to_date('101812 19:16:16', 'MMDDYY HH24:MI:SS' ) where emp_id=12

Similarly, If you want to to query Date column with Time stamp,

select to_char(hire_date,'MMDDYY HH24:MI:SS') from emp

No comments:

Post a Comment