Delphi .NET (2) Database (71) Delphi IDE (89) Network (39) Printing (3) Strings (12) VCL (83) Windows with Delphi (280)
Exchange Links About this site Links to us 
|
Extracting the Month of a Date
This article has not been rated yet. After reading, feel free to leave comments and rate it.
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
Comments:
|
|
|
|
When I use the above syntax (select EXTRACT(MONTH from LastMod) from TableName in Interbase 5.0 I receive the following error 'General SQL error. Token unknown - line 1, char 21 from'
|
|
|
|
|
When I use the above syntax (select EXTRACT(MONTH from LastMod) from TableName in Interbase 5.0 I receive the following error 'General SQL error. Token unknown - line 1, char 21 from'
|
|