Uncategorized

Section 9:96. Date Manipulation – Date Arithmetic

Hive provides a set of built-in functions for performing arithmetic operations on date and time values. Here are some of the common date arithmetic functions in Hive: date_add(date, int days) – This function adds a specified number of days to the given date and returns the resulting date. Example: SELECT date_add(‘2022-03-05’, 7); returns 2022-03-12 date_sub(date, …

Section 9:96. Date Manipulation – Date Arithmetic Read More »

Section 9:95. Date Manipulation – Getting Current Date and Timestamp

CURRENT_DATE: The CURRENT_DATE function returns the current date in ‘yyyy-MM-dd’ format. The syntax for the CURRENT_DATE function is as follows CURRENT_DATE For example: SELECT CURRENT_DATE; — Returns ‘2023-03-04’ (assuming today’s date is March 4, 2023) CURRENT_TIMESTAMP: The CURRENT_TIMESTAMP function returns the current timestamp in ‘yyyy-MM-dd HH:mm:ss’ format.  The syntax for the CURRENT_TIMESTAMP function is as …

Section 9:95. Date Manipulation – Getting Current Date and Timestamp Read More »

Section 9:94. String Manipulation – Reversing and concatenating multiple strings

In Hive, you can manipulate strings by reversing and concatenating them using built-in functions. REVERSE: The REVERSE function is used to reverse the characters in a string. The syntax for the REVERSE function is as follows REVERSE(input_string) For example: SELECT REVERSE(‘Hello World’); — Returns ‘dlroW olleH’ CONCAT: The CONCAT function is used to concatenate multiple …

Section 9:94. String Manipulation – Reversing and concatenating multiple strings Read More »

Section 9:93. String Manipulation – Trimming and Padding

In Hive, trimming and padding functions can be used to manipulate string data. TRIM: The TRIM function is used to remove leading and trailing whitespace or other specified characters from a string. The syntax for the TRIM function is as follows: TRIM([BOTH | LEADING | TRAILING] trim_character FROM input_string) BOTH: Removes the specified characters from …

Section 9:93. String Manipulation – Trimming and Padding Read More »

Section 9:92. String Manipulation – Substr and Split

1. SUBSTR: Extracts a substring from a given string. Example: SELECT SUBSTR(‘Hello World’, 1, 5); Output: Hello  Here is the example 2.In Hive, the SPLIT function is used to split a string into an array of substrings based on a delimiter. The syntax of the SPLIT function is as follows: SPLIT(string str, string delimiter) Here, …

Section 9:92. String Manipulation – Substr and Split Read More »