DATEFORMAT

Formula Explanation

Convert a time string according to a specified time format.

Formula Syntax

dateformat("time value / column number", "time format")
  • Time value: For example: "2022-12-30"
  • Time column: A data column containing time values.
  • Time format:
    • yyyy-MM-dd HH:mm:ss corresponds to year-month-day hour:minute:second;
    • ww corresponds to the week number within the year.
    • You can use any combination, for example, MM-dd will return month-day format.

Usage Example

  1. Convert the time in column CJ2 to "year/month" format, and write the result into column CJ3.
CJ3 = dateformat(CJ2, "yyyy/MM")

dateformat

Valid time formats

yyyy-MM-dd HH:mm:ss

yyyy-MM-dd HH:mm

yyyy-MM-dd H:mm

yyyy-MM-dd HH

yyyy-MM-dd H

yyyy-MM-dd

yyyy-MM

yyyy-ww

ww

yyyy-M-d HH:mm:ss

yyyy-M-d HH:mm

yyyy-M-d H:mm

yyyy-M-d HH

yyyy-M-d H

yyyy-M-d

yyyy-M

yyyy

年/月/日 时/分/秒

yyyy/MM/dd HH:mm:ss

yyyy/MM/dd HH:mm

yyyy/MM/dd H:mm

yyyy/MM/dd HH

yyyy/MM/dd H

yyyy/MM/dd

yyyy/M/d HH:mm:ss

yyyy/M/d HH:mm

yyyy/M/d H:mm

yyyy/M/d HH

yyyy/M/d H

yyyy/M/d

yyyy/ww

ww

日/月/年 时/分/秒

dd/MM/yyyy HH:mm:ss

dd/MM/yyyy HH:mm

dd/MM/yyyy H:mm

dd/MM/yyyy HH

dd/MM/yyyy H

dd/MM/yyyy

d/M/yyyy HH:mm:ss

d/M/yyyy HH:mm

d/M/yyyy H:mm

d/M/yyyy HH

d/M/yyyy H

d/M/yyyy

MM/yyyy

M/yyyy

yyyy

Last Updated: