Transform dates

This page explains how to perform date transformations when you prepare data inthe Wrangler workspace of the Cloud Data Fusion Studio.

The Wrangler workspace supports the date transformations described in thefollowing sections.

Parse dates

To parse column values from a string to a date data type, follow these steps:

  1. Go to Wrangler workspace in Cloud Data Fusion.
  2. On theData tab, go to a column name and click thearrow_drop_downexpander arrow.
  3. SelectParse> Simple date.
  4. Specify the following custom format:MM/dd/yy HH:mm. The format mustmatch the date formatting in the column. If you select a date format thatdoesn't match the dates in the column, you will get incorrect results.

    The data type of the column changes from string toTimestamp_micros.

Get components

The following examples show directives retrieving date components, such as themonth, day, year, minute, second, or hour:

set-column :month Transaction_date.getMonth()set-column :year Transaction_date.getYear()set-column :day_of_week Transaction_date.getDayOfWeek()set-column :day_of_month Transaction_date.getDayOfMonth()set-column :day_of_year Transaction_date.getDayOfYear()set-column :minute Transaction_date.getMinute()set-column :hour Transaction_date.getHour()set-column :second Transaction_date.getSecond()set-column :zone Transaction_date.getZone()

Add time

The following examples show directives that add units of time to the date:

set-column :add_days Transaction_date.plusDays(1)set-column :add_hours Transaction_date.plusHours(200)set-column :add_minutes Transaction_date.plusMinutes(3600)set-column :add_months Transaction_date.plusMonths(3)set-column :add_weeks Transaction_date.plusWeeks(2)set-column :add_years Transaction_date.plusYears(2)set-column :add_seconds Transaction_date.plusSeconds(36000)set-column :add_nonoseconds Transaction_date.plusNanos(3600000)

Subtract time

The following examples show directives that subtract units of time from thedate:

set-column :subtract_days Transaction_date.minusDays(1)set-column :subtract_hours Transaction_date.minusHours(200)set-column :subtract_minutes Transaction_date.minusMinutes(3600)set-column :subtract_months Transaction_date.minusMonths(3)set-column :subtract_weeks Transaction_date.minusWeeks(2)set-column :subtract_years Transaction_date.minusYears(2)set-column :subtract_seconds Transaction_date.minusSeconds(36000)set-column :subtract_nonoseconds Transaction_date.minusNanos(3600000)

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.