Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment effectuer des transformations de date lorsque vous préparez des données dans l'espace de travail Wrangler de Cloud Data Fusion Studio.
L'espace de travail Wrangler est compatible avec les transformations de date décrites dans les sections suivantes.
Analyser les dates
Pour analyser les valeurs de colonne d'une chaîne en tant que type de données de date, procédez comme suit:
Dans l'onglet Données, accédez à un nom de colonne, puis cliquez sur la flèche d'expansion arrow_drop_down.
Sélectionnez Analyser > Date simple.
Spécifiez le format personnalisé suivant: MM/dd/yy HH:mm. Le format doit correspondre à celui de la date dans la colonne. Si vous sélectionnez un format de date qui ne correspond pas aux dates de la colonne, vous obtiendrez des résultats incorrects.
Le type de données de la colonne passe de "chaîne" à Timestamp_micros.
Obtenir des composants
Les exemples suivants montrent des directives qui récupèrent des composants de date, tels que le mois, le jour, l'année, la minute, la seconde ou l'heure:
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eThis page details how to perform date transformations within the Wrangler workspace of Cloud Data Fusion Studio.\u003c/p\u003e\n"],["\u003cp\u003eYou can parse date values from strings into a date data type by specifying a custom format that matches the column's formatting in the Wrangler workspace.\u003c/p\u003e\n"],["\u003cp\u003eThe Wrangler workspace allows for extracting specific date components like month, year, day of the week, hour, and second, from date data types.\u003c/p\u003e\n"],["\u003cp\u003eYou can add or subtract time units, such as days, hours, minutes, months, weeks, years, seconds, or nanoseconds, to date values using specific directives.\u003c/p\u003e\n"]]],[],null,["# Transform dates\n\nThis page explains how to perform date transformations when you prepare data in\nthe Wrangler workspace of the Cloud Data Fusion Studio.\n\nThe Wrangler workspace supports the date transformations described in the\nfollowing sections.\n\nParse dates\n-----------\n\nTo parse column values from a string to a date data type, follow these steps:\n\n1. [Go to Wrangler workspace in Cloud Data Fusion](/data-fusion/docs/concepts/wrangler-overview#navigate-to-wrangler).\n2. On the **Data** tab, go to a column name and click the arrow_drop_down expander arrow.\n3. Select **Parse \\\u003e Simple date**.\n4. Specify the following custom format: `MM/dd/yy HH:mm`. The format must\n match the date formatting in the column. If you select a date format that\n doesn't match the dates in the column, you will get incorrect results.\n\n The data type of the column changes from string to\n `Timestamp_micros`.\n\nGet components\n--------------\n\nThe following examples show directives retrieving date components, such as the\nmonth, day, year, minute, second, or hour: \n\n set-column :month Transaction_date.getMonth()\n\n set-column :year Transaction_date.getYear()\n\n set-column :day_of_week Transaction_date.getDayOfWeek()\n\n set-column :day_of_month Transaction_date.getDayOfMonth()\n\n set-column :day_of_year Transaction_date.getDayOfYear()\n\n set-column :minute Transaction_date.getMinute()\n\n set-column :hour Transaction_date.getHour()\n\n set-column :second Transaction_date.getSecond()\n\n set-column :zone Transaction_date.getZone()\n\nAdd time\n--------\n\nThe following examples show directives that add units of time to the date: \n\n set-column :add_days Transaction_date.plusDays(1)\n\n set-column :add_hours Transaction_date.plusHours(200)\n\n set-column :add_minutes Transaction_date.plusMinutes(3600)\n\n set-column :add_months Transaction_date.plusMonths(3)\n\n set-column :add_weeks Transaction_date.plusWeeks(2)\n\n set-column :add_years Transaction_date.plusYears(2)\n\n set-column :add_seconds Transaction_date.plusSeconds(36000)\n\n set-column :add_nonoseconds Transaction_date.plusNanos(3600000)\n\nSubtract time\n-------------\n\nThe following examples show directives that subtract units of time from the\ndate: \n\n set-column :subtract_days Transaction_date.minusDays(1)\n\n set-column :subtract_hours Transaction_date.minusHours(200)\n\n set-column :subtract_minutes Transaction_date.minusMinutes(3600)\n\n set-column :subtract_months Transaction_date.minusMonths(3)\n\n set-column :subtract_weeks Transaction_date.minusWeeks(2)\n\n set-column :subtract_years Transaction_date.minusYears(2)\n\n set-column :subtract_seconds Transaction_date.minusSeconds(36000)\n\n set-column :subtract_nonoseconds Transaction_date.minusNanos(3600000)\n\nWhat's next\n-----------\n\n- Learn more about [Wrangler directives](/data-fusion/docs/concepts/wrangler-overview#apply_directives)."]]