Datepart in SQL Server And Oracle

SQL Server DATEPART() Function




Syntax :

DATEPART(datepart,date)
datepartAbbreviation
yearyy, yyyy
quarterqq, q
monthmm, m
dayofyeardy, y
daydd, d
weekwk, ww
weekdaydw, w
hourhh
minutemi, n
secondss, s
millisecondms
microsecondmcs
nanosecondns


Examples :
select

Result : 2012
datepart(yyyy,birth_date) from [Table_name]

Oracle : Alternative for DATEPART() Function


SELECT
 SELECT TO_NUMBER(TO_CHAR(SYSDATE, 'HH24')) FROM DUAL
SELECT
current_timestamp,SYSDATE FROM dual
extract(hour FROM current_timestamp) FROM dual

Comments

Popular posts from this blog

Add Serial no in crystal report without coding

Working with Oracle's BLOB and Microsoft's C#

File operations in C# (.net)