Obtaining parts of a date

  • DAY(), MONTH() and YEAR(): They share the syntax of function (date). They can be used for obtaining the day, month, and year part of the date as integers respectivelyFor example, DAY(#24-05-2019#) returns 24.
  • DATEPART: It follows the syntax: DATEPART(date_part,date,[start_of_week]). If the start of the week is not mentioned, then it is determined based on the start day defined in the data source. For example, DATEPART(week,#24-05-2019#) returns 21.
  • DATENAME: The syntax remains the same as DATENAME as DATEPART(date_part,date,[start_of_week]). It is very similar to DATEPART. The key difference is that it will return the values as a string. For example, DATENAME("month",#24-05-2019#) returns May.
  • DATETRUNCThe syntax is the same as DATEPART and DATENAME, as follows: DATETRUNC(date_part, date,[start_of_week])It allows us to not just obtain a date_part but rather truncate the date to that date_part. The syntax is the same as DATEPART and DATENAMEas follows: DATETRUNC(date_part, date,[start_of_week])For example, DATETRUNC("month",#24-05-2019#) returns 01-05-2019 00:00:00.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.127.68