菜鸟的一个问题~~~~~~~(100分)

  • 主题发起人 主题发起人 阿里巴巴
  • 开始时间 开始时间

阿里巴巴

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在delphi用sql查询,数据库是paradox7,怎么样才能取出日期字段的年份和月份呢?
 
说清楚点,若要显示用asstring
 
EXTRACT(extract_field FROM column_reference)

Description

Use EXTRACT to return the year, month, or day field from a DATE or TIMESTAMP column. If the column used with the EXTRACT function contains a NULL value, the return value of EXTRACT will be NULL. If the value is not NULL, EXTRACT returns the value for the specified element in the date, expressed as a SMALLINT.

The Extract_Field parameter may contain any one of the specifiers: YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND. The specifiers YEAR, MONTH, and DAY can only be used with DATE and TIMESTAMP columns. The specifiers HOUR, MINUTE, and SECOND can only be used with TIMESTAMP and TIME columns.

SELECT saledate,

EXTRACT(YEAR FROM saledate) AS YY,
EXTRACT(MONTH FROM saledate) AS MM,
EXTRACT(DAY FROM saledate) AS DD

FROM orders

The statement below uses a DOB column (containing birthdates) to filter to those rows where the date is in the month of May. The month field from the DOB column is retrieved using the EXTRACT function and compared to 5, May being the fifth month.

SELECT DOB, LastName, FirstName

FROM People

WHERE (EXTRACT(MONTH FROM DOB) = 5)
 
covert+substring啊
 
zhanggeye说的对.
 
多人接受答案了。
 
后退
顶部