#example of creating a table with attributes of type date and time
create table c343d30.date_and_time(d date, t time)
create table c343d30.timestamp(ts timestamp)

insert into c343d30.date_and_time values(current date, current time)
#note the space between "current" and "date" and "current" and "time"



insert into c343d30.date_and_time values('11/14/2002','12:12:23')

insert into c343d30.date_and_time values('11-14-2002','12:23')
#the date can have one of the followig formats: 

yyyy-mm-dd,

mm-dd-yyyy 

and mm/dd/yyyy)


insert into c343d30.timestamp values('2002-11-14-12.12.23.00')
#timestamp is a rigid structure of the form yyyy-mm-dd-hh:mm:ss[.ff]



#Useful functions in DB2
DAYNAME 
returns the name of the day contained in the attribute it takes as a parameter

TIMESTAMPDIFF(mode, char(timestamp - timestamp));

returns the difference between two timestamp values calculated in seconds, 
minutes, hours etc, depending on the "mode" specification.


#Usage:

SELECT dayname(d) FROM c343d30.date_and_value

SELECT dayname(ts) FROM c343d30.timestamp

#Other useful functions: MONTHNAME,DATE,DAYS,HOUR,JULIAN_DAY, MICROSECOND, 
MINUTE, MONTH, WEEK,TIMESTAMPDIFF etc.


DB2 also allows expressions of the form 

my_date + 2 DAYS + 2 WEEKS+ 3 YEARS

my_time +  3 MINUTES + 5 HOURS