November 17, 2022 at 3:40 pm
I am trying to Extract Month Name from specific Date field
EXTRACT(MONTH From TO_DATE(PM_PROJ_BRIDGE.SELECT_DTE)) SELECT_MONTH_DAY, this Extract month Number
how can I get month name instead?
November 17, 2022 at 4:14 pm
If you want just the month name, SELECT FORMAT(getdate(), 'MMMM')
But ideally you would return the date as is and format it at display time.
November 17, 2022 at 7:02 pm
If you want just the month name, SELECT FORMAT(getdate(), 'MMMM')
But ideally you would return the date as is and format it at display time.
You don't want to do that if there are a lot of rows involved. In fact, I urge folks to stop using FORMAT in SQL Server because it's so bad for performance that you shouldn't "practice doing it wrong" just for small row-counts.
In SQL Server, SELECT DATENAME(mm,GETDATE()) will do the same thing as what the OP requested and much more quickly.
Here's an article on the subject with some performance tests from simple to fairly complex.
https://www.sqlservercentral.com/articles/how-to-format-dates-in-sql-server-hint-dont-use-format
--Jeff Moden
Change is inevitable... Change for the better is not.
November 17, 2022 at 9:24 pm
Guessing the OP is using MySQL - so this link might be useful: https://www.w3resource.com/mysql/date-and-time-functions/mysql-date_format-function.php
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
November 18, 2022 at 3:08 am
I thought it was someone trying to convert some other dialect to SQL Server. 🙁 I wish people would declare things like that. Offering help in MySQL isn't a problem but it's difficult to guess that when they post in an SQLServer 2019 forum. 😀 I guess the reason they don't is because they probably think that SQL = SQL = SQL when it actually doesn't.
In that's the case, then you certainly pointed at the correct documentation, Jeffrey. Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 18, 2022 at 5:25 pm
I thought it was someone trying to convert some other dialect to SQL Server. 🙁 I wish people would declare things like that. Offering help in MySQL isn't a problem but it's difficult to guess that when they post in an SQLServer 2019 forum. 😀 I guess the reason they don't is because they probably think that SQL = SQL = SQL when it actually doesn't.
In that's the case, then you certainly pointed at the correct documentation, Jeffrey. Thanks.
That all depends on the OP - and it isn't clear if they are looking for help with MySQL or converting from MySQL to SQL Server. If they are trying to convert then your recommendation is correct. Hopefully the OP will respond and let us know for sure.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
November 18, 2022 at 9:32 pm
That all depends on the OP - and it isn't clear if they are looking for help with MySQL or converting from MySQL to SQL Server. If they are trying to convert then your recommendation is correct.
Heh,,. yep... I kinda said that using different words.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply