Crawl and download a date in text format into a Date field in the KG

Hi all,

I am triying to use a crawler to mapping a date in textformat, like “26 Noviembre 2021”, inside a date field in the Knowledge Graph entity.

Would anyone know what kind of transformation I can do to get it?




Hi David!

To convert that Spanish date string into a format that is compatible with date-type fields in the Knowledge Graph, you can utilize a typescript function as a custom transform. To do so, you will create a plugin containing this custom function, upload that plugin to the Yext platform, and use the plugin as a transform while setting up the connector. Here are the steps you could take to accomplish this:

  1. Create a folder on your computer with two files: 1) _resource.json 2) mod.ts.
  2. The _resource.json file should have the following content (or another ID of your choosing) which defines the plugin:
    "$id": "spanishDateFormatter",
    "$schema": ""
  1. The mod.ts file will contain the typescript function you want to apply to that spanish date string in order to change it to a KG-compatible format. There are many ways you could achieve this, I’ve included my own version below which should work for this scenario as long as each date is formatted the same way. Your mod.ts file could look like this:
const months = {
    enero : '01',
    febrero : '02',
    marzo : '03',
    abril : '04',
    mayo : '05',
    junio : '06',
    julio : '07',
    agosto : '08',
    septiembre : '09',
    octubre : '10',
    noviembre : '11',
    diciembre : '12'

export function createDate(str: string) {
  const dateArray = str.split(" ");
  const month = dateArray[2];
  const monthNum = months[month];
  let day = dateArray[0];
  if (day.length === 1) {
    day = `0${day}`;
  const year = dateArray[4];
  const fullDateString = `${year}-${monthNum}-${day}`
  return fullDateString;
  1. Once your plugin is ready to go with the above code in each file, you will use the Yext CLI to upload the plugin to your Yext account. For guidance on using the CLI to manage resources, refer to this guide.

  2. Once you’ve uploaded the plugin via the CLI, you are ready to use it as a custom transform! After clicking “Add Transform”, select “Function” from the dropdown menu and simply select the new createDate function that you made in your mod.ts file to apply to the date string.

You’ll see that this will transform something like “26 de noviembre de 2021” to “2021-11-26” which is the format the Knowledge Graph expects for date fields! For more detailed information on Yext Functions, feel free to take a look at this guide as well.


1 Like