-
concatenating date with time
Hi,
I am an sql beginner and I need help with the following problem.
I have a table called customer in which I have 5 columns.
Date type (date),
hr type (int),
min type (int),
sec (int) and
date_Time type (date).
I need to concatenate date, hr, min, sec and insert in Date_Time column.
Any help is appreciated.
Thanks
-
Okay, since you are a SQL beginner, is that Oracle's SQL or some other vendor's SQL? Why? Because of the datatypes you used. What have you tried so far (just to concatenate without inserting or updating)? For example:
select empno||'|'||name||'|'||hire_date from emp;
1* select empno||'|'||ename||'|'||hiredate from emp
SQL> /
EMPNO||'|'||ENAME||'|'||HIREDATE
-------------------------------------------------------
7369|SMITH|17-DEC-80
7499|ALLEN|20-FEB-81
7521|WARD|22-FEB-81
7566|JONES|02-APR-81
7654|MARTIN|28-SEP-81
7698|BLAKE|01-MAY-81
7782|CLARK|09-JUN-81
-
Datetime
what about the date column.
while concatenating hour, minute and second, date data is missing.
-
Revised Query
update datecon
set date_time = to_date(to_char( trunc(d_date) + hr/24 + (min/(24*60)) + (sec/(24*60*60))
,'dd-mon-yyyy hh24:mi:ss'),'dd-mon-yyyy hh24:mi:ss')
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|