- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
hive query to display Week of the timestamp and its start Date and End Date.
- Labels:
-
Apache HBase
-
Apache Hive
Created 09-25-2017 10:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Created 09-25-2017 11:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
select weekofyear(current_timestamp)
Above query would give you the week of the timestamp.
To get the first day of the week -->
select date_sub(current_timestamp,pmod(datediff(current_timestamp,'1900-01-07'),7));
To get last day of the week -->
select last_day(current_timestamp);
Hope it helps @Gayathri Devi
Created 09-25-2017 11:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
select weekofyear(current_timestamp)
Above query would give you the week of the timestamp.
To get the first day of the week -->
select date_sub(current_timestamp,pmod(datediff(current_timestamp,'1900-01-07'),7));
To get last day of the week -->
select last_day(current_timestamp);
Hope it helps @Gayathri Devi
Created 09-26-2017 11:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I couldn't think of any built in function in hive to handle this scenario.
The other way of doing this is by using something like below:
select from_unixtime(unix_timestamp(current_timestamp)+7200);
7200 implies seconds needed for 2 hours as mentioned in your quetion. You can alter it based on your need.
Instead of the hardcoded value you can pass variable or row_number()over() * 3600 can be used to generate sequentially.
Hope it Helps!!