Skip to main content

I have a field type string contains a date like "20170104" and i have to change it to "2017/01/04".

I have tried de dateformatter (then the model crashes), the stringsearcher (i don't find the right expression) or the attributesplitter but i have no delitimer .

Has somebody a quick way to do this?

Hi @nath, the DateFormatter with these parameters should work.

  • Source Date Format: Unknown - Automatic Detection (or %Y%m%d)
  • Destination Date Format: %Y/%m/%d

Would your Workbnch still crash with the parameters above?


@nath

The dateformatter works fine for your requirement.

source: %Y%m%d

dest format:

%Y/%m/%d


maybe you are including the quotes? Don't.

Does it crash on the dateformatter at all? Or maybe later in process?


I got the crash when i tried using the DateFormatter. I thought that it had something to do because i had merged the tables from shp and csv files together. It worked fine on the shp but not with the csv.


It's not the approach I'd use here, but if you want to split a string without a delimiter you can use a format string to split an attribute, e.g.

4s2s2s

would split 20170104 into

2017

01

04


I got the crash when i tried using the DateFormatter. I thought that it had something to do because i had merged the tables from shp and csv files together. It worked fine on the shp but not with the csv.

Theoretically the DateFormatter should work fine regardless of the source data format. If the workspace always crashes in your specific condition, I would recommend you to contact safe to clarify the cause.

 

In the interim, the StringReplacer would also be a workaround.

 

  • Mode: Replace Regular Expression
  • Text To Replace: ^(....)(..)(..)$
  • Replacement Text: \\1/\\2/\\3

Hi @nath, the DateFormatter with these parameters should work.

  • Source Date Format: Unknown - Automatic Detection (or %Y%m%d)
  • Destination Date Format: %Y/%m/%d

Would your Workbnch still crash with the parameters above?

If running 2016 depending on the build there is a bug that means automatic detection does not work

 

 


Thanks everyone. If I do it with a small amount of data, it works well, so I think it has something to do with an earlier problem that always crashes my workspace. I've contacted Safe and they are looking for a solution.


Reply