0

Convert

Is it  possible  to  convert a Text field into a DAte field and  with the  correct  format  if  possible  ie  DD/MM/YYYY ?

I imported the  entire  database  but  erroneously did  not  set the date field to  date!

4replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Mconneen
    • Mconneen
    • 2 yrs ago
    • Reported - view

    @Dr HH.. 
    Well.. you will not really "convert" the text field in place.. You can create a NEW Date field.. then write a loop to go through all the records and convert them.  

    Let us assume you have YourTextDateField  and its value is "04/04/2020"   (Apr 04, 2020).

    First.. Look up the date function .. you will find date(year, month, day) ... so you will want to "split" your text string as 
    let fldArray := split(YourTextDateField, "/");

    That creates an item array .... ["04", "04", "2020"]

    You can then create a new date field by 

    let YourNewDateField := date(number(item(fldArray, 2)), number(item(fldArray, 1)), number(item(fldArray, 0)))

     

    Disclaimer.. I did not try the code.. so hopefully no type-os.. 

    Like
    • Dr HH
    • Dr_HH
    • 2 yrs ago
    • Reported - view

    I dont  mind  splitting the  function 

    1  I have no hard  syntax  programming  knowledge (total no knowledge)

    2 I have attempted  copying a  formula on the forum to do a  mass repalce  but the the date got  copied  incorrectly

    Like
    • Dr HH
    • Dr_HH
    • 2 yrs ago
    • Reported - view

    Maybe just  copy the characters(numbers ( from the  Text field to a new  date field) then  f,ormat  it

    Like
    • Dr HH
    • Dr_HH
    • 2 yrs ago
    • Reported - view

    mAYBE THIS  CODE  BUT the   numbers corrected allocated   from this text  date of 1975/02/20    to  a Date ieold  1975/02/20 then  formated to DD/MM/YYYY ?

    let firstIndex := index(TextDate, "/");
    let secondIndex := if substr(TextDate, firstIndex + 2, 1) = "/" then
    firstIndex + 2
    else
    firstIndex + 3
    end;
    date(number(substr(TextDate, secondIndex + 1, 4)), number(substr(TextDate, 0, firstIndex)), number(substr(TextDate, firstIndex + 1, secondIndex - firstIndex - 1)))

    Like
Like Follow
  • 2 yrs agoLast active
  • 4Replies
  • 1075Views