Hive Date Format Guide: YYYY-MM-DD Examples

In Hive, the date_format function can be used to format a date in a specific format. Here is an example of formatting a date using the date_format function.

Suppose there is a date column containing date data. To format the date as YYYY-MM-DD, you can use the following query:

SELECT date_format(date_column, 'yyyy-MM-dd') AS formatted_date
FROM table_name;

In the above query, ‘date_column’ is the name of the date column to be formatted, and ‘yyyy-MM-dd’ is the specified date format.

In addition to yyyy-MM-dd, there are other date format characters that can be used to format dates. Some common date format characters include:

  1. Year: A four-digit year
  2. MM: 2nd month
  3. dd: 2-digit date
  4. HH: The hours in the 24-hour clock.
  5. mm: minutes
  6. ss: seconds

You can select the date format that suits your needs.

bannerAds