Re: Dates in SQL?
Date: 1996/10/14
Message-ID: <32622AD9.7858_at_ix.netcom.com>#1/1
Raymond Wan wrote:
>
> Hi, all! Sorta basic question compared to what's in this
> newsgroup...but oh well! At least there's a good chance someone can help
> me! ^_^
>
> Does anyone know how to use [insert and select] dates in Oracle
> v7.x SQL [in SQL*Plus and Pro*C]? I've gotten as far as creating the table:
>
> CREATE TABLE TEMP (
> tempdate DATE not null,
> ...);
>
> But I don't really know how to insert a date into it or select a
> date from it in both SQL*PLUS and PRO*C. I also understand that the DATE
> datatype also stores the time... *shrug*
>
> Thanks!
>
> Raymond Wan
>
> ** ------------------------------------------------ **
> ** Raymond Wan **
> ** Department of Computer Science, **
> ** University of British Columbia **
> ** e-mail: rkwan_at_unixg.ubc.ca **
> ** WWW: http://www.ugrad.cs.ubc.ca/spider/h0h1 **
> ** ------------------------------------------------ **
declare
begin
insert into temp
(tempdata)
values
(to_date ('01-JAN-97'));
end;
This would insert the beginning of next year into the table. If your
DBA left
the default date format alone, you don't even need the to_date function
as
Oracle will figure it out automatically. It would serve you well to
learn about
date/character conversion functions (Chapter 2, PL/SQL User's Guide and
Reference).
For Example: to_date ('31-DEC-1996 23:59:59','DD-MON-YYYY HH24:MI:SS')
would
be the last second of this year.
Loyal Received on Mon Oct 14 1996 - 00:00:00 CEST