Skip to Content
0
Sep 16, 2021 at 07:48 AM

Translate to Hana Date functions

172 Views

Hello,

I'm stumbling over the translation of T-SQL query to Hana:

select * from MyTable

where MyTable.MyDescription like '%' + substring(convert(nvarchar(20),(dateadd(month, -1, getdate())),101),7,4)+'.'+ substring(convert(nvarchar(20),(dateadd(month, -1, getdate())), 101),1,2)+'%'

I'm expecting as a result the selection of lines where MyDescription contains

'%2021.08%' when I'm in September 2021,

'%2021.12%' when I'm in January 2022

I've tried to combine different Hana functions - CURRENT_DATE, TO_VARCHAR, ADD MONTHS...

But all the time I don't get the syntax right.

Would you kindly help me to get this conversion right, please?

Kind Regards

Marie-Yolande