# What's wrong with this quarterly date formula?

This formula was created by Frodoman back in July and I am just using it now.  But I am getting an error requiring a string after FALSE.  Can someone tell me where I went wrong?

If month(currentdate) = 4 then
{MBRSUM.CREATE_DATE} & " in " & date(1,1,year(currentdate)) & " to " &  date(1,3,year(currentdate))
else
If month(currentdate) = 7 then
{MBRSUM.CREATE_DATE} & " in " & date(1,4,year(currentdate)) & " to " &  date(1,6,year(currentdate))
else
If month(currentdate) = 10 then
{MBRSUM.CREATE_DATE} & " in " & date(1,7,year(currentdate)) & " to " &  date(1,9,year(currentdate))
else
If month(currentdate) = 1 then
{MBRSUM.CREATE_DATE} & " in " & date(1,10,year(currentdate)) & " to " &  date(1,12,year(currentdate))
else
false
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Each formula in crystal report returns a value, the value can be in any type. And if you use IF THEN ELSE statement, the return type is depends on the first define return type.

eg)
IF month(currentdate) = 4 then
"some string here"
else
true

this will cause an syntax error because it expect a string after else. the correct syntax will be
IF month(currentdate) = 4 then
"some string here"
else
"must be string as well"

So in your case, you should change the "false" to some string instead.

dylan
Author Commented:
I am not very familiar with strings.  Could you give me an example I could use with this string dylanyee?

Thank you.
Author Commented:
The FALSE was supposed to end the formula.  It was supposed to prevent monthly values from showing up when it wasn't the current quarter (since I am setting it to run monthly in Crystal Enterprise).
Commented:
glabossi, in your case, it depends on you to decide what should the formula return if it wasn't the belongs to current quarter, the example below simply replace the false to "", you could change it to anything. such as "false"

If month(currentdate) = 4 then
{MBRSUM.CREATE_DATE} & " in " & date(1,1,year(currentdate)) & " to " &  date(1,3,year(currentdate))
else
If month(currentdate) = 7 then
{MBRSUM.CREATE_DATE} & " in " & date(1,4,year(currentdate)) & " to " &  date(1,6,year(currentdate))
else
If month(currentdate) = 10 then
{MBRSUM.CREATE_DATE} & " in " & date(1,7,year(currentdate)) & " to " &  date(1,9,year(currentdate))
else
If month(currentdate) = 1 then
{MBRSUM.CREATE_DATE} & " in " & date(1,10,year(currentdate)) & " to " &  date(1,12,year(currentdate))
else
""
Author Commented:
I tried putting in the "" after else and  I received an error (a number must be between 1 and the number of days in a month) for this line in the formula:

date(1,1,year(currentdate))
Author Commented:
Any help here?
Commented:
yes, your date formula is wrong.
you should use date(year, month, day)
for your case is date(year(currentdate), 1, 1)

Experts Exchange Solution brought to you by