我在 MySQL 中有 sql 查询:
SELECT
distinct
us.user_id as user_id,
us.ab_id,
users.name,
users.role,
users.is_admin,
DATE_FORMAT('2013-11-05T10:06:21+04:00', '%Y-%m') as month_m
FROM attach_offices as us
LEFT JOIN users ON users.id = user_id
WHERE us.`ab_id` = 999999999 and
DATE_FORMAT('2013-11-05T10:06:21+04:00', '%Y-%m') between DATE_FORMAT(dt_begin, '%Y-%m') and DATE_FORMAT(`dt_end`, '%Y-%m')
如何将其转换为 Oracle 11g?我写这样的东西:
SELECT
distinct
attach_offices.user_id as user_id,
attach_offices.ab_id,
users.name,
users.role,
users.is_admin,
to_date('2013-11-05T10:06:21+04:00', 'YYYY-MM') as month_m
FROM attach_offices
LEFT JOIN users ON users.id = user_id
WHERE attach_offices.ab_id = 999999999 and
to_date('2013-11-05T10:06:21+04:00', 'YYYY-MM') between to_date(to_char(dt_begin, 'YYYY-MM'), 'YYYY-MM') and to_date(to_char(dt_end, 'YYYY-MM'), 'YYYY-MM')
但它不起作用。日期的问题,当我使用2013-11-05T10:06:21+04:00
它时它不起作用但是当我使用2013-11
它时它是工作的