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

Hepl - Year and Month functions

Status
Not open for further replies.

abc567

Programmer
Jul 8, 2009
45
US
Hi,
I have a date field and i want to display it as
200101
200102
...

I used ToText(Year(datefield)) &ToText(Month(Datefield))
and i am getting
2,0011
2,0012
....


Thanks ..
 
totext(year(datefield),0,"")&totext(month(datefield),0)

or if you are only doing this for viewing purposes... go to the field formating ... select custom style and manipulate your output from that screen



_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Thanks CoSpringsGuy..

The output is 20011, 20012..
I need 200101, 200102,....


 
Code:
IF (month(datefield)) <10 THEN
totext(year(datefield),0,"")& "0" & totext(month(datefield),0)
ELSE
totext(year(datefield),0,"")&totext(month(datefield),0)

Hope this helps! [smile]

Mike
--------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure, in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
Author R.A. Salvatore via "Drizz't"
 
totext(year(datefield),0,"")
&
replicatestring("0",len(totext(month(datefield),0))-2)
&
totext(month(datefield),0)

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Thank you buddy MCuthill...
Appreciate your help..
 
CoSpringsGuy's answer dint work..
It says " The no. of copies of string is too large or not an integer "


Any ways i got the answer thru MCuthill..

Thanks CoSpringsGuy
 
yep .. sorry about that .. I see where my solution went wrong .. was working on a fix but Im glad you got the correct response!!

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Use:

totext(year(datefield),"0000")&totext(month(datefield),"00")
 
Wow..!!
Thanks lbass..
That was short and sweet...
 
I tip my hat to you lbass, always rocking the most concise solutions! [smile]

Mike
--------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure, in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
Author R.A. Salvatore via "Drizz't"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top