Teradata SQL - First Day of a Month

event 2021-02-04 visibility 4,349 comment 0 insights
more_vert
insights Stats
Raymond Raymond Code Snippets & Tips

Code snippets and tips for various programming languages/frameworks. All code examples are under MIT or Apache 2.0 license unless specified otherwise. 

Introduction

In Teradata, we can derive the first day of the month from a specified date.

Code snippet

The following code snippet shows the month start date of the current month:

SELECT CURRENT_DATE - EXTRACT(DAY FROM CURRENT_DATE) + 1 AS MONTH_START_DATE;

Output:

MONTH_START_DATE

1 1/02/2021


Similarly, table column or DATE expressions can be used with the function.

SELECT DATE'2021-12-31' - EXTRACT(DAY FROM DATE'2021-12-31') + 1 AS MONTH_START_DATE;

Output:

MONTH_START_DATE

1 1/12/2021


More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts