DatePart in MSSQL date & time fieldWe can collect a particular date part from any date and time field of MSSQL table. We have to specify which part of the date and time is required. You can get a list of constants used for formatting DatePart function.Getting Month using DatePart functionWe have one date and time field as issue_dt and we want to know the month of this date and time data.
We will get month between 1 to 12 here.
Getting the Day of the year
Here we will get the value from 1 to 365 ( days of the year )
Same way we can use the table below and get all the parts from a date and time field of MSSQL table.
Let us try this inside one sql query and get the data
This article is written by plus2net.com team.
Be the first to post comment on this article : | ||||||||||||||||||||||||