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

Month/Year

Status
Not open for further replies.

vbjohn

Programmer
Aug 23, 2001
67
0
0
US
I am putting a formula in Crystal that will give me the Month and Year only in this format... 06/05. How could I do this?

ToText(Month ({Emp.DateStarted})) +"/"+ ToText(Year({Emp.DateStarted}))

and I get this...

6.00/2,005.00

What should the formula be?
 
Great! Why didn't I think of that.
 
Try ToText(Month ({Emp.DateStarted}), "00") & "/" & ToText(Year({Emp.DateStarted}), 0). The "00" ensures you get 06/2005 rather than 6/2005, which is what you want if you are going to sort using the field.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
You could just have formatted your datefield itself to appear as the month and year by going to the format->date->customize tab and selecting Month: 03, Day: None, Year: 1996 (or whatever depending upon your version). The advantage is that it will sort correctly by date and you can work with the datefield as a date.

-LB
 
You can't use the formatting engine to derive MM/yy from a date.
 
I'm sorry about this, but maybe I need to clear out the cobwebs. How? :p
 
As in my post of 12:38. To get the year in yy format, you would choose "99". Or maybe I'm missing something about what you mean, Naith? This just changes the display of the date, while leaving it in date format.

-LB
 
That would result in 6/99 as opposed to 06/99. I thought the point was that there should be a leading zero. Maybe I misinterpreted the initial requirement.
 
O.M.G. I only just woke up and re-read your post. Of course customisation would achieve this. I initially thought you were making reference to selecting one of the preset M/YY formats.

Apologies, LB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top