需要帮助。
我正在尝试从toad中提取数据,其中一列(EFFECTIVE_FROM)包含时间戳中的日期dd / mm / yy hh:mi:ss:mmmAM例如(2015年5月8日下午2:14:19)但我希望DD-MM-YYYY的日期即2015年5月8日
我使用以下查询
请帮助
SELECT B.USER_NAME AS CREATED_BY, A.CREATION_DATE, C.USER_NAME, A.LAST_UPDATE_DATE, A.PFIZER_ITEMCODE, A.SYSTEM_ITEMCODE AS ORACLE_ITEM_CODE,
A.ITEM_DESCRIPTION, A.BATCH_NUMBER, A.MFR_CODE, A.MFR_DESC AS MFR_DESCRIPTION, A.MFR_DATE, A.EXPIRY_DATE, A.EFFECTIVE_FROM
FROM xxdhl_pf_batch_pricing A,
fnd_user B,
fnd_user c
where 1=1
AND A.CREATED_BY = B.USER_ID
AND A.LAST_UPDATED_BY = C.USER_ID
AND A.SYSTEM_ITEMCODE = 'xx' AND A.BATCH_NUMBER = 'yy'
答案 0 :(得分:1)
假设EFFECTIVE_FROM
是日期或时间戳字段,您可以使用TO_CHAR
函数:
SELECT TO_CHAR(A.EFFECTIVE_FROM,'DD-MON-YYYY'), B.USER_NAME AS CREATED_BY, A.CREATION_DATE, C.USER_NAME, A.LAST_UPDATE_DATE, A.PFIZER_ITEMCODE, A.SYSTEM_ITEMCODE AS ORACLE_ITEM_CODE,
A.ITEM_DESCRIPTION, A.BATCH_NUMBER, A.MFR_CODE, A.MFR_DESC AS MFR_DESCRIPTION, A.MFR_DATE, A.EXPIRY_DATE, A.EFFECTIVE_FROM
FROM xxdhl_pf_batch_pricing A,
fnd_user B,
fnd_user c
where 1=1
AND A.CREATED_BY = B.USER_ID
AND A.LAST_UPDATED_BY = C.USER_ID
AND A.SYSTEM_ITEMCODE = 'xx' AND A.BATCH_NUMBER = 'yy'
答案 1 :(得分:0)
您可以使用TO_DATE()
,如下所示:
SELECT B.USER_NAME AS CREATED_BY,
A.CREATION_DATE,
C.USER_NAME,
A.LAST_UPDATE_DATE,
A.PFIZER_ITEMCODE,
A.SYSTEM_ITEMCODE AS ORACLE_ITEM_CODE,
A.ITEM_DESCRIPTION,
A.BATCH_NUMBER,
A.MFR_CODE,
A.MFR_DESC AS MFR_DESCRIPTION,
A.MFR_DATE,
A.EXPIRY_DATE,
to_date(A.EFFECTIVE_FROM, 'DD-MON-YYYY')
FROM xxdhl_pf_batch_pricing A, fnd_user B, fnd_user c
where 1 = 1
AND A.CREATED_BY = B.USER_ID
AND A.LAST_UPDATED_BY = C.USER_ID
AND A.SYSTEM_ITEMCODE = 'xx'
AND A.BATCH_NUMBER = 'yy'
答案 2 :(得分:0)
如果您希望将月份写成您的示例(2015年5月8日),则不需要“MM”。 MM会给你一个月号,所以你最终会得到'08 -05-2015'。
使用:
to_char(A.EFFECTIVE_FROM,'DD-MON-YYYY')
请参阅此处的格式模型: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm