Converting Date to String and Vice Versa

  • Last update:  2022-04-26
  • 1. Overview

    1.1 Expected effect

    Sometimes, you need to convert the "Text" or "Value" field to the "Date" field type, for example, convert the numerical "1621221876057" field to the standard "Date" field, as shown in the following figure:

    2021-08-18_9-38-30.png

    1.2 Implementation ideas

    Use the self-service dataset "Add column" and implement it through "formula/function".

    Note: This paper lists some common conversion methods, which will be supplemented according to the actual data structure.

    2. Operation steps

    2.1 Add columns in self-service dataset

    Add a self-service dataset, select the numerical field under the corresponding dataset (this file takes the fixed data value 1621221876057 as an example), click "+" to add a new column, as shown in the following figure:

    2021-08-18_9-38-05.png

    Note: the functions and fields in the formula box need to be selected by clicking the selection area on the left, and cannot be entered manually.

    2.2 View the effects

    See more details in section 1.2.

    3. Other conversion examples

    Original field
    Conversion methodConversion results Attentions
    Wed1/15/07TODATE("Wed1/15/07","EEEMM/dd/yy","en")2007-01-15 00:00:00String converse to Time
    2021/02/07WedTODATE("2021/02/07Wed","yyyy/MM/ddEEE","en")2021-02-07 00:00:00String converse to Time
    21/02/07WedTODATE("21/02/07Wed","yy/MM/ddEEE","en")2021-02-07 00:00:00String converse to Time
    21/02/07/WedTODATE(replace("21/02/07/Wed","/W","W"),"yy/MM/ddEEE","en")2021-02-07 00:00:00String converse to Time
    1621221876057TODATE(1621221876057)2021-05-17 11:24:36Time type (the original field is 13 bit timestamp, accurate to milliseconds)
    1621221876TODATE(1621221876*1000)2021-05-17 11:24:36Time type (the original field needs 10 bit timestamp, accurate to the second level), 1s = 1000ms
    2020/05/22TODATE("2020/05/22")2020-05-22 00:00:00Convert YYMMDD/YYMM text type to "Date" type
    20200522TODATE("20200522","yyyyMMdd")2020-05-22 00:00:00Convert YYMMDD/YYMM text type to "Date" type
    202005TODATE("202005","yyyyMM")2020-05-01 00:00:00Convert YYMMDD/YYMM text type to "Date" type

    Three fields

    Year——2020

    Month——5

    Day——22

    DATE(Year,Month,Day)2020-05-22 00:00:00To save multiple fields of year, month and day, you need to process multiple fields into one date field
    2020-02-02FORMAT("2020-02-02","yyyyMM")202002Convert YYMMDD to YYMM
    2020-05-22TODATE(LEFT("2020-05-22",10))2020-05-22Remove the "hour, minute and second" from the data in the format of hour, minute and second of month, year and day
    2018/12/1/Sat 8:55:00TODATE(replace("2018/12/1/Sat 8:55:00","W","W"),"yyyy/MM/dd/EEE HH:mm:ss","en")2018-12-01 08:55:00String (including day of week) converse to time type


    附件列表


    主题: Advanced Data Analysis
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy