cancel
Showing results for 
Search instead for 
Did you mean: 

decimal to datetime conversion

former_member198401
Active Contributor
0 Kudos

Hi All,

I want to convert decimal values to datetime values. Looks silly but its kind of tricky 🙂

for e.g

20170723231018 value has decimal(15,0)

20170723231018.1340000 value has decimal(21,7)

I converted the decimal value to varchar and it gets converted but when I try to convert the varchar string to datetime using to_date() it says that it cannot convert the string to date format YYYY.MM.DD

Target Table is HANA and Source is SAP BW table

Any help or hint would be appreciated.

Regards

Arun Sasi

Accepted Solutions (1)

Accepted Solutions (1)

former_member198401
Active Contributor

Cast to varhcar(14) for Date with Timestamp
to_date(CAST(DATETIME,'VARCHAR(14)'),'YYYYMMDDHH24MISS')

Output will be in datetime column

2017.07.23 23:10:18.000000000



Cast to varchar(22) and then convert to datetime for including Date with timestamp with sub seconds
to_date(CAST(DATETIME_SUBSECONDS,'VARCHAR(22)'),'YYYYMMDDHH24MISS.FF')

Output:

2017.07.24 00:13:47.420000000

Answers (0)