Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ToText formula returns "Bad Number Format String" error 1

Status
Not open for further replies.

marlow1208

Technical User
Nov 6, 2008
16
US
I am using the following formula and get a "Bad Number Format String" error:

If month(currentdate) = 1
then ToText((year(currentdate)- 1),"yyyy")
else ToText(year(currentdate),"yyyy")

If I remove the formatting argument on the second line of code as the following, it works:

If month(currentdate) = 1
then ToText(year(currentdate)- 1)
else ToText(year(currentdate),"yyyy")

I need the formatting argument included. Can anyone tell me what I am doing wrong?
 
Are you just trying to remove the comma from the year? If so, try this:

ToText (Year(currentdate-1),0, "")
 
That worked just as I needed it to. Thank you very much!
 
The problem with your original formula was that you were using date formatting on a number (year). You could also have used:

If month(currentdate) = 1
then ToText(year(currentdate)- 1,"0000")
else ToText(year(currentdate),"0000")

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top