Skip to Content
author's profile photo Former Member
Former Member

HANA date format

Hello Gurus,

I need some help on below issue in HANA modeler-

I have date in 2015-10-09 stored in table. I want to convert to YYYYMMDD format in table. The date is stored as sql type "'nvarchar" 10 string.

Please suggest the best approach. this is one time activity.

Thanks

Pallavi

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 11, 2015 at 04:35 AM

    Hi Pallavi,

    Since the data in the table is of NVARCHAR datatype, the TO_CHAR function would fail.

    It issue can be resolved in the below following way:

    create table date_test(col1 nvarchar(10));

    insert into date_test values('2015-10-09');

    select to_char(to_date(col1, 'YYYY-MM-DD'), 'YYYYMMDD')

    from date_test;

    You need to use to_char(to_date(col1, 'YYYY-MM-DD'), 'YYYYMMDD')

    Regards,

    Anil

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 10, 2015 at 05:39 PM

    Hello Pallavi,

    Use TO_CHAR(DATE,8)

    select to_char(date,8) from "schema_name"."Table_name" ;

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.