SELECT
	po.profile_option_name
  , NVL(users.user_name,'SITE')
  , pov.profile_option_value
FROM
	fusion.fnd_profile_options       po
  , fusion.fnd_profile_option_values pov
  , fusion.fnd_session_users         users
WHERE
	po.profile_option_id = pov.profile_option_id
	AND pov.level_value  = users.user_guid(+)
	-- AND po.profile_option_name IN ('FND_LANGUAGE','FND_TERRITORY' ,'FND_DATE_FORMAT' ,'FND_NUMBER_FORMAT' ,'FND_TIME_FORMAT' ,'FND_CURRENCY' ,'FND_TIMEZONE')
	AND UPPER(users.user_name) LIKE UPPER('%' || COALESCE(:ip_username, :xdo_user_name) || '%')
;

select
	:xdo_user_name as USER_ID
	-- , :xdo_user_roles              as USER_ROLES
  , :xdo_user_report_oracle_lang as REPORT_LANGUAGE
  , :xdo_user_report_locale      as REPORT_LOCALE
  , :xdo_user_ui_oracle_lang     as UI_LANGUAGE
  , :xdo_user_ui_locale          as UI_LOCALE
  , :xdo_user_timezone           as UI_LOCALE
from
	dual
;

SELECT
	TO_CHAR(FROM_TZ(CREATION_DATE, DBTIMEZONE) at time zone
	(
		select
			:xdo_user_timezone
		from
			dual
	)
	,'YYYY-MM-DD HH24:MI:SS ') creation_date
  , creation_date              creation_date2
  , :XDO_USER_TIMEZONE
  , :xdo_user_name name
FROM
	ap_invoices_all
where
	TRUNC(FROM_TZ(creation_date, DBTIMEZONE) at time zone
	(
		select
			:xdo_user_timezone
		from
			dual
	)
	) <=:p_date
order by
	creation_date
;

SELECT
	FROM_TZ (TO_TIMESTAMP (TO_CHAR (imt.transaction_date, 'YYYY-MM-DD HH24:MI:SS')) ,DBTIMEZONE) AT TIME ZONE
	(
		SELECT
			:xdo_user_timezone
		FROM
			DUAL
	)
FROM
	DUAL
;

SELECT
	TO_CHAR(FROM_TZ(CREATION_DATE, DBTIMEZONE) at time zone
	(
		select
			:xdo_user_timezone
		from
			dual
	)
	,'YYYY-MM-DD HH24:MI:SS ') creation_date
  , creation_date              creation_date2
  , :XDO_USER_TIMEZONE
  , :xdo_user_name name
FROM
	ap_invoices_all
where
	TRUNC(FROM_TZ(creation_date, DBTIMEZONE) at time zone
	(
		select
			:xdo_user_timezone
		from
			dual
	)
	) <=:p_date
order by
	creation_dates
;