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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you format a date within a parameter formula?

Status
Not open for further replies.

stormtrooper

Programmer
Apr 2, 2001
266
CA
Hi there. I have a formula which displays the min and max values (dates) for a parameter. The formula is

totext(minimum({?Parameter})) + " to " + totext(maximum({?Parameter}))

What my question is is that the date format within the parameter itself is 'm/d/yyyy'. And what I want to know is how do I get that to display in my report as 'yyyy/m/d'?

Thanks
 
Try this out:
Code:
dim yyyy as string
dim mm as string
dim dd as string
dim FromDate as string
dim ToDate as string

yyyy=totext(year(minimum({?Date Range})),0,"")
mm=totext(month(minimum({?Date Range})),0,"")
dd=totext(day(minimum({?Date Range})),0,"")

FromDate=yyyy+"/"+mm+"/"+dd

yyyy=totext(year(maximum({?Date Range})),0,"")
mm=totext(month(maximum({?Date Range})),0,"")
dd=totext(day(maximum({?Date Range})),0,"")

ToDate=yyyy+"/"+mm+"/"+dd

formula=FromDate +" to " + ToDate
 
Dear StormTrooper,

Why not try this:

//formula - Crystal 8, should work in all versions

totext(minimum({?Parameter}),"yyyy/M/d") + " to " + totext(maximum({?Parameter})"yyyy/M/d")

//Formula end

Check out all the formatting options for text in help. There are an amazing number of things you can do.

ro
Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
rosemaryl, you get another gold star. I forgot all about in line formatting!
 
Dear StormTrooper,

I made a small error when copying the formula: (I forgot the comma after the comma in the second statement <maximum({?Parameter})&quot;>

Should be:

//formula - Crystal 8, should work in all versions

totext(minimum({?Parameter}),&quot;yyyy/M/d&quot;) + &quot; to &quot; + totext(maximum({?Parameter}),&quot;yyyy/M/d&quot;)

//Formula end

Sorry about that!

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Dear Storm Trooper:

What is the error message?

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Dear StormTrooper,

I just installed 7.0 on a test server, ran the report with the formula and it works fine with no errors.

I am copying the exact formula from the formula editor and pasting here - so replace my parameter fields with yours:

totext(minimum({?From}),&quot;yyyy/M/d&quot;) + &quot; to &quot; + totext(maximum({?To}),&quot;yyyy/M/d&quot;)

Hope this is helpful,

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Ok, it works. I forgot to set my parameter back from string to date. Thanks for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top