How to convert a date to a string in Google Sheet

后端 未结 6 2134
轮回少年
轮回少年 2021-02-03 20:13

I am trying to figure out how to convert a date into a string in a google sheet.

I have one date field that has varying formats. I want create another column that\'s lit

相关标签:
6条回答
  • 2021-02-03 20:21

    =TEXT(now(),"yyyy-MM-dd hh:mm:ss")

    This cell is now a string.

    0 讨论(0)
  • 2021-02-03 20:27

    You can use the TEXT function.

    =Text(cellReference, "mm-dd-yyyy")
    
    0 讨论(0)
  • 2021-02-03 20:27

    I don't understand why you need this. Just figured out that there's no way to detect the format of dates in google sheets. But you may use getDisplayValues property. Paste this code into script editor:

    function repeatAsText(A1Notation, sheet) {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      if (sheet) { sheet = ss.getSheetByName(sheet); }
      else { sheet = ss.getActiveSheet(); }
      var range = sheet.getRange(A1Notation);
    
      return range.getDisplayValues();
    }
    

    and then use it as ususl formula:

    =repeatAsText("A1:A3")

    A1Notation -- string like "A1" or "B3:AD15".

    sheet -- name of sheet, like "Sheet1". It is optional, use ActiveSheet if omitted

    0 讨论(0)
  • 2021-02-03 20:33

    Use the TEXTJOIN function. Give an empty delimiter, TRUE for the ignore empty, the referenced cell as text1, and don't supply anything for text2.

    =TEXTJOIN("",TRUE,A1)
    

    Done.

    0 讨论(0)
  • 2021-02-03 20:37

    to concatenate text to date you can do this:

    =CONCATENATE("today is: ", TEXT(HOY(), "dd-mm-yyyy"))
    
    
    0 讨论(0)
  • 2021-02-03 20:38
    1. copy the column to another column
    2. select the copied column
    3. go to menu 'Format' --> 'Number' --> 'Plain text'
    0 讨论(0)
提交回复
热议问题