cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert NVARCHAR to DATE data type in calculation view ?

pavneet_rana
Active Participant
0 Kudos

Hi to all,

How to convert NVARCHAR to DATE data type in calculation view.

Example: I have 2  date filed in calculation view with type NVARCHAR, and need to calculate difference between field1 and field2, so

I have created calculated column with expression daysbetween(field1,field2), but it gives error while viewing data.

So we need to convert field1,field2 from NVARCHAR to DATE FIELD.

HOW TO DO THAT ?

Regards

Pavneet Rana

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Pavneet,

Please try this :

SELECT DAYS_BETWEEN (TO_DATE(START_DATE), TO_DATE(END_DATE)) FROM DUMMY;

or add this in your calculated column

DAYS_BETWEEN (TO_DATE(START_DATE), TO_DATE(END_DATE))

Note : Assuming START_DATE and END_DATE will be your fields in NVARCHAR

Regards,

Charles

former_member210482
Active Participant
0 Kudos

Hi Charles,

Good to meet you here. Here pavneet is referring to caculated column created in graphical view. So this wont work in that case right? Correct me if i am wrong.

Regards,

Safiyu

0 Kudos

Hi Safiyu,

You are correct in this regard.

we need to use daysbetween() instead of DAYS_BETWEEN().

Thanks for correcting me.

Regards,

Charles

pavneet_rana
Active Participant
0 Kudos

Hi,

Thanks for reply ,,

daysbetween(date('field1'),date('field2'))

Regards

Pavneet Rana

Answers (2)

Answers (2)

former_member210482
Active Participant
0 Kudos

Hi Pavneet,

Use daysbetween(date(field1),date(field2))

Regards,

Safiyu

Former Member
0 Kudos

Hi Pavneet,

You can use the conversion function date() first, please have a look at

Conversion Functions - SAP HANA Modeling Guide - SAP Library

Best regards,

Wenjun