Is there a function in SAP HANA which has the same semantics as age
in PostgreSQL, that is, which returns the difference between a given time stamp and the current time stamp?
SAP HANA中是否有与PostgreSQL中的年龄相同的语义,即返回给定时间戳和当前时间戳之间的差异?
I know
ADD_YEARS(COLUMN_NAME, 2) <= NOW()
in SAP HANA would correspond to
在SAP HANA中将对应于
(extract (year from age( COLUMN_NAME )) <= 2 )
in PostgreSQL. Unfortunately, this is not an option for me, since I don't have the information <= 2
. What I am looking for is a way to translate age(COLUMN_NAME)
(PostgreSQL) to SAP HANA.
在PostgreSQL中。不幸的是,这不是我的选择,因为我没有信息<= 2.我正在寻找的是将年龄(COLUMN_NAME)(PostgreSQL)翻译成SAP HANA的方法。
Any ideas?
4 个解决方案
#1
2
try this:
SECONDS_BETWEEN(<timeA>, <timeB>)
#2
1
With SPS12 there is the YEARS_BETWEEN()
function available:
使用SPS12,可以使用YEARS_BETWEEN()函数:
select years_between(current_date, add_years(current_date, -10)) from dummy;
10
#3
0
select floor(days_between(to_date(timestamp1), to_date(timestamp2))/365) from dummy;
从虚拟中选择楼层(days_between(to_date(timestamp1),to_date(timestamp2))/ 365);
it shall do the trick
它应该做的伎俩
#4
0
This worked for me to calculate age in years in SPS11:
这对我来说在SPS11中计算年龄:
if(format(now(), 'MMDD') >= format("DateOfBirth", 'MMDD'),
int(component(now(), 1)) - int(component("DateOfBirth", 1)),
if(int(component(now(), 1)) = int(component("DateOfBirth", 1)), 0,
int(component(now(), 1)) - int(component("DateOfBirth", 1)) - 1))
#1
2
try this:
SECONDS_BETWEEN(<timeA>, <timeB>)
#2
1
With SPS12 there is the YEARS_BETWEEN()
function available:
使用SPS12,可以使用YEARS_BETWEEN()函数:
select years_between(current_date, add_years(current_date, -10)) from dummy;
10
#3
0
select floor(days_between(to_date(timestamp1), to_date(timestamp2))/365) from dummy;
从虚拟中选择楼层(days_between(to_date(timestamp1),to_date(timestamp2))/ 365);
it shall do the trick
它应该做的伎俩
#4
0
This worked for me to calculate age in years in SPS11:
这对我来说在SPS11中计算年龄:
if(format(now(), 'MMDD') >= format("DateOfBirth", 'MMDD'),
int(component(now(), 1)) - int(component("DateOfBirth", 1)),
if(int(component(now(), 1)) = int(component("DateOfBirth", 1)), 0,
int(component(now(), 1)) - int(component("DateOfBirth", 1)) - 1))