Search code examples
sqlibm-data-studio

Selecting all data from a table where it is the first of the month


I am using Data Studio to query a large table in a relational database. I am attempting to get all of the data where a certain column with the data type of DATE is the first of the month. The dates in the columns range from about 1990 to 2023 and are in the YYYY-MM-DD format.

I am not very proficient with SQL and all answers I've found for anything similar don't seem to make any sense to me.

Any help would be appreciated.

SELECT * FROM data_table
WHERE date_column ... is the first of the month;

Solution

  • I'm assuming DB2 because you've tagged IBM Data Studio:

    Can you use DAYOFMONTH() like this?:

    SELECT * FROM data_table
    WHERE DAYOFMONTH(date_column) = 1;