0

Form the client I need to pass a SYSDATE argument to PL/SQL. In the server it need to be converted to date, for which iam using TO_DATE(in_timestamp, 'DD-MON-YYYY HH24:MI:SS'); What should be the data type of in_timestamp?

5
  • 1
    :If you are passing SYSDATE to in_timestamp then datatype will be of DATE type .Are you returnig the same variable after converting it ? Commented Apr 9, 2012 at 10:04
  • i will not be returning any value from procedure. Commented Apr 9, 2012 at 10:16
  • :then go for date as mentioned by Erkan Haspulat in his answer Commented Apr 9, 2012 at 10:17
  • 1
    Do you mean SYSDATE, the oracle pseudo-column, or just a system generated date? Commented Apr 9, 2012 at 15:05
  • Naming something in_timestamp when you are looking for a data may be confusion. People may think you are asking for a timestamp instead of a date. Commented Apr 9, 2012 at 17:18

2 Answers 2

5

SYSDATE is itself a date, and it seems like the target field is also a date (Since you used TO_DATE()). Thus you don't actually need a conversion here.

Just pass SYSDATE and use it in your PL/SQL block, meaning in_timestamp should be a date.

Sign up to request clarification or add additional context in comments.

Comments

0

As far as TO_DATE is concerned you can have CHAR, VARCHAR or VARCHAR2(recommended) basically it should be of String type as following examples suggest:-

to_date('2003/07/09', 'yyyy/mm/dd') would return a date value of July 9, 2003.
to_date('070903', 'MMDDYY') would return a date value of July 9, 2003.
to_date('20020315', 'yyyymmdd') would return a date value of Mar 15, 2002.

You can find more information related to TO_DATE at this link,

EDIT

*"However, if you are passing sysdate you dont't need to use TO_DATE again because it is already a Date value..."*as mentioned by @Gaurav and Hence the dataType of in_timestamp should be DATE..

1 Comment

:If he's passing sysdate then why he should be recommmended to store that in varchar*?,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.