Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 06-27-2018 12:18 PM
Hi,
I am trying to convert a postgres Greenplum function to Hive and encountered the below problem:
cast(from_unixtime(unix_timestamp(current_timestamp - interval 1 Month 9 days),'YYYYMM') as int)
This is working in pyspark when I use a Hive context but the same is failing in Ambari. Can anyone explain this? What should we use instead of interval to reduce 1 month and 9 days? We cant use 39 days as this will sometimes be 39 and sometimes 40
Regards,
Souveek
Created 06-27-2018 11:23 PM
Hey @Souveek Ray!
What about this?
select date_add(add_months(current_timestamp,-1),-9);Hope this helps!
Created 06-27-2018 11:23 PM
Hey @Souveek Ray!
What about this?
select date_add(add_months(current_timestamp,-1),-9);Hope this helps!
Created 07-02-2018 07:13 AM
Thanks a lot, this worked. but for my requirement I used the below syntax
from_unixtime(unix_timestamp(date_add(add_months(current_timestamp,-1),-9) ,'yyyy-MM-dd'), 'yyyyMM')
Thanks a lot.
Regards,
Souveek
Created 07-02-2018 07:17 AM
Good to know @Souveek Ray !
Please if the issue is solved, I'd kindly ask you to accept as an answer. Doing this will help other users to find the answer and will engage the contributors to keep doing the good job 🙂