database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
ㆍDB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
DB2 Q&A 1478 게시물 읽기
No. 1478
db2에도 to_timestamp같은 함수가 있는지요
작성자
토이
작성일
2007-12-27 13:35
조회수
10,456

'19820606000000' 형태의 스트링 날짜를 timestamp로 넣어야하는데.. 


java소스상에서 


 String ISQL=

        "insert into certs ("+

        "serial,status,laststatus,issue_date,expire_date,event_date,"+

        "policy,userid,timeid,cid,name,mail)"+

        "values(?,?,?, " +

         "?,?,?,"+

        "?,?,?,?,?,?)";



 DB_obj.pStmtBatch.setString(1, serial);

 DB_obj.pStmtBatch.setString(2, status);

                DB_obj.pStmtBatch.setString(3, laststatus)

                DB_obj.pStmtBatch.setString(4, issue_date);

             DB_obj.pStmtBatch.setString(5, expire_date);

             DB_obj.pStmtBatch.setString(6, event_date);

                DB_obj.pStmtBatch.setString(7, policy);

                DB_obj.pStmtBatch.setString(8, userid);

                DB_obj.pStmtBatch.setString(9, timeid);

                DB_obj.pStmtBatch.setString(10, cid);

                DB_obj.pStmtBatch.setString(11, name);

                DB_obj.pStmtBatch.setString(12, mail);



이렇게 바로 넣어주니 에러가 나더라구요..


2008-01-26 23:59:59.0 형태로 들어가야하는데... 쩝

 너무 급한데 답변좀 부탁드려요 ㅜㅜ  


 String ISQL=

        "insert into certs ("+

        "serial,status,laststatus,issue_date,expire_date,event_date,"+

        "policy,userid,timeid,cid,name,mail)"+

        "values(?,?,?, " +

         "to_timestamp(?,"+yyyy-mm-dd hh24:mi:ss)"

        "to_timestamp(?,"+yyyy-mm-dd hh24:mi:ss)"

        "to_timestamp(?,"+yyyy-mm-dd hh24:mi:ss)"

        "?,?,?,?,?,?)";


이렇게 해봐도 에러가나던데...

이 글에 대한 댓글이 총 1건 있습니다.
TIMESTAMP

Converts the input(s) into a timestamp value.
Argument Options
• If only one argument is provided, it must be (one of):
• A timestamp value.
• A character representation of a timestamp (the microseconds are optional).
• A 14 byte string in the form: YYYYMMDDHHMMSS.
• If both arguments are provided:
• The first must be a date, or a character representation of a date.
• The second must be a time, or a character representation of a time.

SELECT TIMESTAMP(’1997-01-11-22.44.55.000000’)
,TIMESTAMP(’1997-01-11-22.44.55.000’)
,TIMESTAMP(’1997-01-11-22.44.55’)
,TIMESTAMP(’19970111224455’)
,TIMESTAMP(’1997-01-11’,’22.44.55’)
FROM staff
WHERE id = 10;
Figure 419, TIMESTAMP function example

-> 14자리 string을 timestamp로 바꾸는 예제입니다. 

db2 "values(timestamp('19820606000000'))"       

1                        
--------------------------
1982-06-06-00.00.00.000000

--님이 2007-12-27 16:18에 작성한 댓글입니다.
이 댓글은 2007-12-27 16:22에 마지막으로 수정되었습니다. Edit
[Top]
No.
제목
작성자
작성일
조회
1481MSSQL과 DB2간의 차이점, 장단점 등등을 비교설명해놓은 문서없을까요? [1]
김건우
2008-01-04
9438
1480COM.ibm.db2.jdbc.app.DB2Blob@???
울고싶어라
2007-12-28
9207
1479union all 하면 값이 바뀌네요... [3]
초보
2007-12-27
9426
1478db2에도 to_timestamp같은 함수가 있는지요 [1]
토이
2007-12-27
10456
1477스트링을 timestamp타입으로 넣는방법도 좀 부탁드릴께요~ [2]
토이
2007-12-21
9303
1476No suitable driver ㅠㅠ 모르겠습니다. [1]
초보자
2007-12-20
10034
1475[급]쿼리인데 좀 도와주십시요.
배성수
2007-12-18
8622
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2023 DSN, All rights reserved.
작업시간: 0.050초, 이곳 서비스는
	PostgreSQL v16.1로 자료를 관리합니다