Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am trying to convert date time in Crystal report. My date is 12 2017 and i want to convert it into december 2017 but it gives me error

<pre>MonthName (val(left({Table1.MonthYear},2))) + ' - ' + right({Table1.MonthYear},4)
a string is required.

Note: it works on current month year but gives error in previous month.

What I have tried:

<pre>MonthName (val(left({Table1.MonthYear},2))) + ' - ' + right({Table1.MonthYear},4)
Posted
Updated 29-Jan-18 20:38pm

1 solution

ToText(CDate({Table1.MonthYear}),"MMM yyyy");

or
local datevar a :=CDate(Left({Table1.MonthYear},2) +' - ' +  Right({Table1.MonthYear},4));
 local numbervar y := Year (a); local numbervar d := Month (a); Date (d, y);


Try above and let me know.
 
Share this answer
 
v3
Comments
Member 13651104 30-Jan-18 2:50am    
It gives error
MonthName ToText(CDate({Table1.MonthYear}),"MMM yyyy")

the remaining text doesnot appear to be the part of formula
[no name] 30-Jan-18 2:57am    
Any syntax mistake like semi colon or anything?
Member 13651104 30-Jan-18 2:59am    
ok i will check
[no name] 30-Jan-18 3:01am    
BTW CDate is a function
Member 13651104 30-Jan-18 3:16am    
cdate is inbuilt function?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900