Skip to main content

Community,

I have a SQL column RECEIPT_INFO_CFV.ARRIVAL_DATE which is showing like below, 

8/15/2022 5:14:12 PM

which function I can use in SQL to retrieve Month in a column, and Year in a column, for above sample,  SQL result should return like below,

Month       Year

8                 2022

 

Thank you.

Hi @ronhu 

 

You can use following syntax to get month and year

select to_char(ARRIVAL_DATE , 'MM') Month,to_char(ARRIVAL_DATE , 'YYYY') Year  from RECEIPT_INFO_CFV

 

Hope it helps!

Damith


@dsj it is working, thank you very much.


Hi @ronhu ,

 

Try EXTRACT function. see the example. 

 

SELECT 
EXTRACT(MONTH FROM ARRIVAL_DATE) AS month,
EXTRACT(YEAR FROM ARRIVAL_DATE) AS year
FROM RECEIPT_INFO_CFV;

 


@Banu Liyanapathirana It is working. Thank you.


Reply