function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nick PaivaNick Paiva 

Formula: Convert today's date to month and year?

Hey guys,

Simple formula question. I'm trying to take a date field and return a year and month.

In my flow, I'm trying to make a Get Records criteria:

Due_Date__c - Equals - (This month and year formula). 

I currently have: DATE(YEAR(TODAY()),MONTH(TODAY()),1)

And it seems to be returning: March 1st, 2019. Rather than March 2019. 

Thanks,

Nick
Titis WulandariTitis Wulandari
Maybe this formula will  help

CASE(MONTH(Due_Date__c),1, 'January',
2, 'February',
3, 'March',
4, 'April',
5, 'May',
6, 'June',
7, 'July',
8, 'August',
9, 'September',
10, 'October',
11, 'November',
12, 'December',''
)+' '+TEXT(YEAR(TODAY()))
 
Nick PaivaNick Paiva
Thanks for the help!

I think the formula would have worked, but it didn't like it because of the "TEXT," as the system is looking for a DATE. Which perhaps that means what I'm trying to achieve might not be possible?
Nick PaivaNick Paiva

Is there potentially a way to add a month to a date?

 

So I could do, criteria:

Due Date - greater than or equal - DATE(YEAR(TODAY()),MONTH(TODAY()),1)
and
Due Date - Less than - DATE(YEAR(TODAY()),MONTH(TODAY()),1) (Plus one month)

 

So it'd be greater than or equal to March 1st, 2019, but less than April 1st, 2019.

Alain CabonAlain Cabon
Hi,

You can also test that :MONTH( due date ) = MONTH ( today ) and YEAR( due date ) = YEAR( today ) 
 
Ajay K DubediAjay K Dubedi
Hi Nick,

I am not sure for you scenario  but try below code:
YEAR(TODAY()),MONTH(TODAY())
or
DATE(YEAR(TODAY()),MONTH(TODAY()))
for more info visit:
https://www.excel-exercise.com/function-date-year-month-day/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Deepali KulshresthaDeepali Kulshrestha
Hi Nick, 
You can try the below formula: 
TEXT(MONTH(TODAY())) + "," + TEXT(YEAR(TODAY()))
I've tried the same in my org and seems useful to me. Please have a look to the Screeshots I've attached that may be helpful to you:

User-added image

User-added image

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Chris Louder 1Chris Louder 1
In response to last message Nick, yes. You would just add 1 to the month entry
Is there potentially a way to add a month to a date? So I could do, criteria:
Due Date - greater than or equal - DATE(YEAR(TODAY()),MONTH(TODAY()),1)
and
Due Date - Less than - DATE(YEAR(TODAY()),MONTH(TODAY()),1) (Plus one month)
 So it'd be greater than or equal to March 1st, 2019, but less than April 1st, 2019.
 
You would want
Due Date - Less than - DATE( YEAR(TODAY())  , MONTH(TODAY()) +1 , 1 )