Loading datetype

I need to load the date and time as 01/07 / 2022,13:43.
I am unable to change the date format.

I have created the Convert Token function to the correct date format.
extern “C” void convertMDY_HM (const char* const iToken[], uint32_t iTokenLen[], uint32_t iTokenNum, char* const oToken, uint32_t& oTokenLen)
TG does not allow me to assign the result of a function to DATETIME.
Error: Vertex “Test”'s attribute “Date” expects a(n) DATETIME, but the token function’s output type is STRING.

Is it possible to write a function whose result will be assigned to the DATETIME type?
Is it possible to convert result from my function to DATETIME?

@Juliusz Just for clarification you’re loading from CSV using a UDT (User Defined Token) to convert the format to meet the DATETIME standard input. The error above is raised after running through the UDT?

When I’m working with datetimes I usually always convert to epoch prior to loading because it’s a lot easier to convert from epoch to datetime. Could you also take that route?

Loading a DATETIME attribute

When loading data into a DATETIME attribute, the GSQL loader will automatically read a string representation of DateTime information and convert it to internal DateTime representation. The loader accepts any of the following string formats:

  • %Y-%m-%d %H:%M:%S (e.g., 2011-02-03 01:02:03)
  • %Y/%m/%d %H:%M:%S (e.g., 2011/02/03 01:02:03)
  • %Y-%m-%dT%H:%M:%S.000z (e.g., 2011-02-03T01:02:03.123z, 123 will be ignored)
  • %Y-%m-%d (only date, no time, e.g., 2011-02-03)
  • %Y/%m/%d (only date, no time, e.g., 2011/02/03)
  • Any integer value (Unix Epoch time, where Jan 1, 1970 at 00:00:00 is integer 0)
1 Like

The function works fine. I can create a loading job in gsql.
CREATE LOADING JOB load_job_costtest FOR GRAPH Testadd { DEFINE FILENAME file1 = “/home/tigergraph/costtest.csv”; LOAD file1 TO VERTEX Test VALUES($0, convertMDY_HM($6,$7), convertMDY_HM($6,$7)) USING SEPARATOR=",", HEADER=“true”, EOL="\n"; }

In GraphStudio I cannot assign the result of this function to the DATATIME field.
Error: Vertex “Test” 's attribute “date” expects a (n) DATETIME, but the token function’s output type is STRING.

Is there any way to do this in GraphStudio?