0% found this document useful (0 votes)
29 views1 page

Date Fields in Oracle Vs SQL Server

n,

Uploaded by

srikanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

Date Fields in Oracle Vs SQL Server

n,

Uploaded by

srikanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Oracle Date Queries

========================================
select to_char(DATE_ROW_LAST_UPDATED,'YYYY') as year,
COUNT(DATE_ROW_LAST_UPDATED) as count from ADM_COMMON_ORDER_DIM
group by to_char(DATE_ROW_LAST_UPDATED,'YYYY') order by
to_char(DATE_ROW_LAST_UPDATED,'YYYY')

select to_char(trunc(DP_REWORK),'YYYY') as year, COUNT(DP_REWORK) as count


from TBVM25_VW
group by to_char(trunc(DP_REWORK),'YYYY') order by to_char(trunc(DP_REWORK),'YYYY')
====================================
SQL Queries Date Queries
====================================
select year(ReworkDate) as year , count(ReworkDate) as count from TBVM25 where plant='V1'
group by year(ReworkDate) order by year(ReworkDate)

select datepart(year,ReworkDate) as year , count(ReworkDate) as count from TBVM25 where


plant='V1'
group by datepart(year,ReworkDate) order by datepart(year,ReworkDate)

select query to get only date from datetime in sql server:


==========================================================

select top 10 date_of_last_change from adm.adm_open_order_fact--Datetime

select top 10 cast(date_of_last_change as date) from adm.adm_open_order_fact--Only date


from datetime
select top 10 convert(date, date_of_last_change ) from adm.adm_open_order_fact--Only date
from datetime
select top 10 cast(date_of_last_change as time) from adm.adm_open_order_fact--Only time
from datetime

select query to get only date from datetime in Oracle:


========================================================

select TRUNC(date_of_last_change) dt FROM adm.adm_open_order_fact;


SELECT to_char(date_of_last_change, 'DD.MM.YYYY') dt from adm.adm_open_order_fact;

********** List All Stored Procedure Modified in Last N Days ******


SELECT name,modify_date,create_date
FROM sys.objects
WHERE type = 'P'
AND DATEDIFF(D,modify_date, GETDATE()) < 2

You might also like