我想将字符串值转换为水晶报表中的日期时间
日期格式
05-10-7-AAAA (mm-dd-year(2017)-AAAA)
05-23-3-00 (mm-dd-year(2013)-00)
...
我想要的输出是
10-May-2017
23-May-2013
...
我的好参考是How to convert string value to proper datetime format&以下尝试让我犯了错误:
Date({ORDERCHECKVIEW.LOTNUMBER}[4 to 5], ***{ORDERCHECKVIEW.LOTNUMBER}[1 to 2], {ORDERCHECKVIEW.LOTNUMBER}[7]***) //Too many arguments have been given to this function
&安培;
DateValue({ORDERCHECKVIEW.LOTNUMBER}) //Bad date format string
提前非常感谢你,我会尽可能地回应你!
答案 0 :(得分:0)
创建一个新公式并应用以下代码。 {Command.mydate}将替换为您的字段
local StringVar mDate;
local StringVar mMonth;
local StringVar mDay;
local StringVar mYear;
//local StringVar mSuffix:= StrReverse(left(StrReverse({Command.mydate}),instr(StrReverse({Command.mydate}),"-",1)-1)); // to get suffix
mDate:= left({Command.mydate},InStrRev ({Command.mydate},"-" )-1); // get dd
mMonth:= left(mDate,2); // get MM
mDay := Mid (mDate,4 ,2 ); // get YYYY
mYear := totext(2010 + CDbl (right(mDate,InStr(StrReverse(left({Command.mydate},InStrRev ({Command.mydate},"-" )-1)),"-") -1 )),0,""); // transform 2017
cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay)); // this will display dd-MM-YYYY may not display as 01 for dd but you can always customise this in the GUI the important point is this is now a date field