Default Date Format - When Inserting from Date to Varchar Field

General
Enthusiast

Default Date Format - When Inserting from Date to Varchar Field

Hi,
I am using a Stored Procedure and in that I have a statement to select a Date Field and Insert into a Varchar field. The fields are dynamic, that is the input column can be a date or a varchar field or an integer. Thus, I cannot explicitly type cast the field. Now, when I am inserting the date field into the Varchar field, it is always inserting in 'yy/mm/dd' format, i.e., stripping of the first 2 digits of the year.

I tried Setting the date format as 'ANSIDATE' in the Stored procedure, but it is not accepting that. When I tried in BTEQ, it accepted, but did not gave the result as 'yyyy/mm/dd'. It still gives as 'yy/mm/dd'. I guess there should be some setting somewhere we can do so that the default date format for the session is taken as 'yyyy/mm/dd'. Can anyone please help. I am providing an example below.

Date : 2000/04/20

Varchar field when inserted: 00/04/20.
2 REPLIES
Enthusiast

Re: Default Date Format - When Inserting from Date to Varchar Field

Hi All,

    Does anyone have any solution to this problem.

Mithun

Teradata Employee

Re: Default Date Format - When Inserting from Date to Varchar Field

Have you tried the SET SESSION DATEFORM for the session that compiles the SP?