betweenGo

Updating/Reading Dates

by Frank Kim on Sep.29, 2005, under Oracle

I always forget how to do this.

UPDATE foo SET bar_date = TO_DATE( '2005-09-29', 'YYYY-MM-DD') WHERE foo_id=51

SELECT TO_CHAR(bar_date, 'yyyy-mm-dd hh24:mi:ss') FROM foo;

SELECT * FROM foo WHERE bar_date > TO_DATE('08/16/2006', 'MM/DD/YYYY')

When you need a date in a pinch for inserting test data use sysdate.

INSERT INTO foo (bar_date) VALUE (sysdate)

A good article about this is Oracle, SQL, Dates and Timestamps.

  • Share/Bookmark

Related posts:

  1. Date and Timestamp Repository Data Types
  2. Playing with Dates in Java
  3. Inserting a text value with special characters
  4. Determining Permissions for a User
  5. Retrieving the Source from the Database


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!