Listing 4: Uses DATEPART to Extract and Return Datetime Value Elements Alter Procedure converted_times_2 AS --Normal declarations DECLARE @mydatetime DATETIME --Special declarations DECLARE @myms int DECLARE @myss int DECLARE @mymi int DECLARE @myhh int DECLARE @mydd int DECLARE @mymm int DECLARE @myyyyy int --Store datetime value and convert it to selected formats SET @mydatetime=getdate() --Extract datetime parts for display SET @myms = DATEPART(ms,@mydatetime) SET @myss = DATEPART(ss,@mydatetime) SET @mymi = DATEPART(mi,@mydatetime) SET @myhh = DATEPART(hh,@mydatetime) SET @mydd = DATEPART(dd, @mydatetime) SET @mymm=DATEPART(mm,@mydatetime) SET @myyyyy = DATEPART(yyyy, @mydatetime) SELECT @myyyyy AS 'Year', @mymm AS 'Month', @mydd AS 'Day of month', @myhh AS 'Hour', @mymi AS 'Minute', @myss AS 'Second', @myms AS 'Millisecond'