DelphiFAQ Home Search:
General :: Programming :: Delphi :: Database
Database development with Delphi. Includes issues with BDE, ADO and InterBase.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Extracting the Month of a Date

Question:
My table has a field LastMod of type DATE which contains the last time the record was modified. Now I'd like to group records by the month they were modified. How can I elegantly extract the month from a DATE field?

Answer:
Use the EXTRACT() function. The syntax is:

EXTRACT(modifier FROM fieldname)

where modifier can be:

YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, WEEKDAY, YEARDAY.

Example:

select EXTRACT(MONTH from LastMod) from TableName


Generated 16:27:41 on Feb 17, 2019