Skip to Content
0

decimal to datetime conversion

Aug 08, 2017 at 03:14 PM

119

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Arun Sasi Aug 08, 2017 at 05:42 PM
1

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

Share
10 |10000 characters needed characters left characters exceeded