Converting string to date in Crystal Reports

戏子无情 提交于 2019-12-25 02:38:18

问题


I'm new to Crystal Reports, I'm trying to extract and display month and year from the string (In DB the data type of the column is varchar). Following is an example of the data.

05-JAN-12 11.49.28.000000000 AM

I need it in following format

Jan-12

I have used cDate to convert the string to date format but was unsuccessful, maybe I didn't do it right way.


回答1:


Alter the formula to extract the date portion, then convert it to a date:

DateValue(Split("05-JAN-12 11.49.28.000000000 AM")[1])

Apply formatting to the field as desired.




回答2:


This may work

Date (Year ({reportfield}) * 10000 + Month ({reportfield}) * 100 + Day ({reportfield}))

Then format the field to display the date as your choosing.




回答3:


MonthName(DatePart ("m", <<Date field>>))+"-"+totext(DatePart ("yyyy", <<DAtefield>>),0,"")


来源:https://stackoverflow.com/questions/22658847/converting-string-to-date-in-crystal-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!