且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单个数字到年份以及连字符的高级转换

更新时间:2023-02-10 15:21:03

创建一个新公式并应用下面的代码。 {Command.mydate}将替换为您的字段

Create a new Formula and apply the code below. {Command.mydate} will be replaced with your field

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