Articles in this section
Category / Section

How to subtract the days from the date field in Bold BI?

Published:

DATESUB:

It is a built-in function used to subtract a specified time interval from a given date or datetime value.

SQL:

Syntax:

DATESUB(numeric_expression, date_expression)
  • numeric_expression: The value to subtract from the date. This can be an integer representing days, months, or years.
  • date_expression: The date from which the value will be subtracted.

Example:

Suppose we want to subtract 7 days from a specific date:

 DATESUB(7, [Date_field])

image.png

MySQL:

Syntax:

DATE_SUB(date, INTERVAL value interval)
  • date: The date from which the value will be subtracted.
  • value: The value to subtract.
  • interval: The unit of time (e.g., DAY, MONTH, YEAR).

Example:

DATE_SUB("2017-06-15", INTERVAL 10 DAY);

image.png

PostgreSQL:

Syntax:

DATESUB(numeric_expression, date_expression)
  • numeric_expression: The value to subtract from the date. This can be an integer representing days, months, or years.
  • date_expression: The date from which the value will be subtracted.

Example:

DATESUB(1,[hiredate])

image.png

We can also use the DATESUB() function or the subtraction operator (-) with the INTERVAL keyword to subtract time intervals from dates.

Syntax:

date_column - INTERVAL 'value unit';

Example:

[hiredate] - INTERVAL '1 DAY'

image.png

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
SM
Written by Siranjeevi Murugan
Updated:
Comments (0)
Please  to leave a comment
Access denied
Access denied