Skip to content

Latest commit

 

History

History
68 lines (57 loc) · 2.25 KB

File metadata and controls

68 lines (57 loc) · 2.25 KB
title language
WEEKS_SUB
en

Description

Subtracts a specified number of weeks from a specified date or time value (i.e., subtracts weeks * 7 days).

Syntax

WEEKS_SUB(<date_value>, <week_period>)

Required parameters

必选参数

Parameter Description
date_value DATE or DATETIME type input value.
week_period Integer, representing the number of weeks to subtract (positive to decrease, negative to increase).

Example

  1. Subtract one week from the datetime 2020-02-02 02:02:02

    select weeks_sub("2020-02-02 02:02:02", 1);
    +-------------------------------------+
    | weeks_sub('2020-02-02 02:02:02', 1) |
    +-------------------------------------+
    | 2020-01-26 02:02:02                 |
    +-------------------------------------+
    
  2. Subtract one week from the date 2020-02-02

    select weeks_sub("2020-02-02", 1);
    +--------------------------------------------+
    | weeks_sub(cast('2020-02-02' as DATEV2), 1) |
    +--------------------------------------------+
    | 2020-01-26                                 |
    +--------------------------------------------+