[Solved] Extract Month Name from Date

Discuss the spreadsheet application
Post Reply
Phillip
Posts: 102
Joined: Wed Jan 09, 2013 1:50 pm

[Solved] Extract Month Name from Date

Post by Phillip »

Is this possible? I tried =TEXT(MONTH(a2);"MMMM").
I am sure that when I first entered this function, it worked, but after a few more entries it now it does not. Was I hallucinating?
Attachments
Month name from date.ods
(11.1 KiB) Downloaded 231 times
Last edited by Phillip on Mon Jul 08, 2019 9:27 am, edited 3 times in total.
Open Office 4.1.11, Windows 7 Professional 64-bit
User avatar
keme
Volunteer
Posts: 3699
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Extract Month Name from Date

Post by keme »

Try =TEXT(A2;"MMMM"). The format draws the month name only from the date code in A2.

Your formula first extracts the month number, and then uses that as a date code to extract month from. MONTH(x) will return something between 1 and 12, which - as a date code - can be two months. 1 is 31st of December, and the rest are days in January...
Phillip
Posts: 102
Joined: Wed Jan 09, 2013 1:50 pm

Re: Extract Month Name from Date

Post by Phillip »

Brilliant! I was able to replace a complicated formula by =TEXT(B3;"YY-MM MMMM") to give "19-03 April".
- This is to rename a series of files via the DOS 'FOR' command.
Open Office 4.1.11, Windows 7 Professional 64-bit
User avatar
robleyd
Moderator
Posts: 5055
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: [Solved] Extract Month Name from Date

Post by robleyd »

For this particular task, a dedicated tool might be more appropriate - there is a tool named Bulk Rename Utility that seems like it might work for you. bulkrenameutility[dot]co[dot]uk to save you searching.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
User avatar
keme
Volunteer
Posts: 3699
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: [Solved] Extract Month Name from Date

Post by keme »

robleyd wrote:For this particular task, a dedicated tool might be more appropriate - there is a tool named Bulk Rename Utility that seems like it might work for you. bulkrenameutility[dot]co[dot]uk to save you searching.
Well, on the command line the "ren" command is a dedicated tool for renaming files, and the "for" command is a dedicated tool for bulk operations. ;)

That said, the Bulk Rename Utility does provide some options not available elsewhere that I know of, so definitely appropriate to mention, of course. The utility comes with a command line tool, so it can also be used if the renaming is part of a greater workflow involving "batch scripts" or the like (or if Phillip simply prefers working on the command line).
 Edit: The command line tool is a separate download, not an integrated part of the GUI "Bulk Rename Utility". Sorry if anyone has been misled by my less-than-accurate comment - now struck out. 
User avatar
robleyd
Moderator
Posts: 5055
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: [Solved] Extract Month Name from Date

Post by robleyd »

Well, on the command line the "ren" command is a dedicated tool for renaming files, and the "for" command is a dedicated tool for bulk operations.
<pedant>That makes two tools plus Calc, for a total of 3; so one tool is better :super: </pedant>

Sorry Keme, just had to say it!
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
Phillip
Posts: 102
Joined: Wed Jan 09, 2013 1:50 pm

Re: [Solved] Extract Month Name from Date

Post by Phillip »

FYI. I have a series of files that I want to add a date to the file name XXX as " YYYY-MM MMM" - as "XXX 2018-08 August", each file a different date - hence a spreadsheet of files & dates
I will give Bulk Rename utility a look but for now, as an ex-programmer I often do things like:
Dir <files> > A.csv, type dates in Calc & create new names, -> .bat scripts using 'for' to "Ren <oldname> <newname>, etc
Do you think I should get out more?
Apologies as not really CALC specific but perhaps an example of how useful spreadsheets can be!
Open Office 4.1.11, Windows 7 Professional 64-bit
Post Reply