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

    • DATEADD (datepart , number , date )

  • – includes CONVERT, CAST, TRY_CONVERT


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
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)

Â