Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I extract the month from a date in SQL?

Laurie Huth
Contributor
December 5, 2022

I need a column that just returns the Month of my Due Date.

Here is what I have so far...

SELECT 'Key',
FORMATWIKI(SUM('Summary')) AS 'The Summary',
FORMATWIKI(SUM('Due')) AS 'Due Date',

(something here) AS 'Month of Due Date'

 

2 answers

2 votes
Katerina Rudkovskaya _Stiltsoft_
Atlassian Partner
December 13, 2022

Hi @Laurie Huth,

It seems that this question is a duplicate of this one, so please find the answer there.

2 votes
David Freitez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2022

Hi @Laurie Huth

It would depend on the field type, for instance, if if it is a date/datetime you can use the function: MONTH(date)

Explained better here:

https://learnsql.com/cookbook/how-to-get-the-month-from-a-date-in-mysql/#:~:text=Use%20the%20MONTH()%20function%20to%20retrieve%20a%20month%20from,column%20of%20date%20data%20type).

https://www.geeksforgeeks.org/month-function-in-mysql/

Hopefully this answers your question.

Regards,
David

Laurie Huth
Contributor
December 6, 2022

Thank you. I've tried these suggestions. However, the column is created but there is no data (i.e., integers) that appear. It's just empty cells. Not sure what I am doing wrong.

 

Any other suggestions?

David Freitez
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 7, 2022

Hi @Laurie Huth

Can you share the complete SQL to see if I can catch something in it ?

Regards

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events