Skip to main content
Skip table of contents

SQL Date Manipulations: CONVERT, DATEADD, EOMonth & More

Date manipulation refers to the process of altering, calculating, or formatting date and time values.

Date Parsing

Extract date components (e.g., year, month, day) from strings or formatted dates.

Functions include CONVERT, YEAR MONTH, DAY, DATEPART.

Date Parsing with Date Arithmetic

Extract date components (e.g., year, month, day) from strings or formatted dates and then perform operations like addition or subtraction on dates to calculate durations, intervals, or new date values.

Related Pages

Related Pages from Microsoft


TESTS

DATEADD( … ) Returns Data Type of date Argument

Syntax: DATEADD (datepart , number , date )

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

image-20240506-025723.png

Query in SSMS

SQL
select DATEADD(Day, -1, GETDate()) as DateTime,
    DATEADD(Day, -1, CONVERT(Date, GETDate())) as DateType
 INTO aaatemp;|
image-20240506-025830.png

Results (shown in Design pane)

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.