存档

2010年5月 的存档

返回农历日期信息

2010年5月30日 没有评论

ChineseDate(iptDate : Date;Type : Integer) : Text[100]

//This is created by Yeats.
//天干名称
TianGan[1]:= ‘甲’;
TianGan[2]:= ‘乙’;
TianGan[3]:= ‘丙’;
TianGan[4]:= ‘丁’;
TianGan[5]:= ‘戊’;
TianGan[6]:= ‘己’;
TianGan[7]:= ‘庚’;
TianGan[8]:= ‘辛’;
TianGan[9]:= ‘壬’;
TianGan[10]:= ‘癸’;

//地支名称
dizhi[1]:=’子’;
dizhi[2]:=’丑’;
dizhi[3]:=’寅’;
dizhi[4]:=’卯’;
dizhi[5]:=’辰’;
dizhi[6]:=’巳’;
dizhi[7]:=’午’;
dizhi[8]:=’未’;
dizhi[9]:=’申’;
dizhi[10]:=’酉’;
dizhi[11]:=’戌’;
dizhi[12]:=’亥’;

//属相名称
ShuXiang[1]:=’鼠’;                                           
ShuXiang[2]:=’牛’;
ShuXiang[3]:=’虎’;
ShuXiang[4]:=’兔’;
ShuXiang[5]:=’龙’;
ShuXiang[6]:=’蛇’;
ShuXiang[7]:=’马’;
ShuXiang[8]:=’羊’;
ShuXiang[9]:=’猴’;
ShuXiang[10]:=’鸡’;
ShuXiang[11]:=’狗’;
ShuXiang[12]:=’猪’;

//农历日期名
DayName[1]:=’*’;
DayName[2]:=’初一’;
DayName[3]:=’初二’;
DayName[4]:=’初三’;
DayName[5]:=’初四’;
DayName[6]:=’初五’;
DayName[7]:=’初六’;
DayName[8]:=’初七’;
DayName[9]:=’初八’;
DayName[10]:=’初九’;
DayName[11]:=’初十’;
DayName[12]:=’十一’;
DayName[13]:=’十二’;
DayName[14]:=’十三’;
DayName[15]:=’十四’;
DayName[16]:=’十五’;
DayName[17]:=’十六’;
DayName[18]:=’十七’;
DayName[19]:=’十八’;
DayName[20]:=’十九’;
DayName[21]:=’二十’;
DayName[22]:=’廿一’;
DayName[23]:=’廿二’;
DayName[24]:=’廿三’;
DayName[25]:=’廿四’;
DayName[26]:=’廿五’;
DayName[27]:=’廿六’;
DayName[28]:=’廿七’;
DayName[29]:=’廿八’;
DayName[30]:=’廿九’;
DayName[31]:=’三十’;

//农历月份名
MonName[1]:=’*’;
MonName[2]:=’I?;
MonName[3]:=’二’;
MonName[4]:=’三’;
MonName[5]:=’四’;
MonName[6]:=’五’;
MonName[7]:=’六’;
MonName[8]:=’七’;
MonName[9]:=’八’;
MonName[10]:=’九’;
MonName[11]:=’十’;
MonName[12]:=’冬’;
MonName[13]:=’腊’;

//公历每月前面的天数
MonthAdd[1]:=0;
MonthAdd[2]:=31;
MonthAdd[3]:=59;
MonthAdd[4]:=90;
MonthAdd[5]:=120;
MonthAdd[6]:=151;
MonthAdd[7]:=181;
MonthAdd[8]:=212;
MonthAdd[9]:=243;
MonthAdd[10]:=273;
MonthAdd[11]:=304;
MonthAdd[12]:=334;

//农历数据
NongliData[1]:=2635;
NongliData[2]:=333387;
NongliData[3]:=1701;
NongliData[4]:=1748;
NongliData[5]:=267701;
NongliData[6]:=694;
NongliData[7]:=2391;
NongliData[8]:=133423;
NongliData[9]:=1175;
NongliData[10]:=396438;
NongliData[11]:=3402;
NongliData[12]:=3749;
NongliData[13]:=331177;
NongliData[14]:=1453;
NongliData[15]:=694;
NongliData[16]:=201326;
NongliData[17]:=2350;
NongliData[18]:=465197;
NongliData[19]:=3221;
NongliData[20]:=3402;
NongliData[21]:=400202;
NongliData[22]:=2901;
NongliData[23]:=1386;
NongliData[24]:=267611;
NongliData[25]:=605;
NongliData[26]:=2349;
NongliData[27]:=137515;
NongliData[28]:=2709;
NongliData[29]:=464533;
NongliData[30]:=1738;
NongliData[31]:=2901;
NongliData[32]:=330421;
NongliData[33]:=1242;
NongliData[34]:=2651;
NongliData[35]:=199255;
NongliData[36]:=1323;
NongliData[37]:=529706;
NongliData[38]:=3733;
NongliData[39]:=1706;
NongliData[40]:=398762;
NongliData[41]:=2741;
NongliData[42]:=1206;
NongliData[43]:=267438;
NongliData[44]:=2647;
NongliData[45]:=1318;
NongliData[46]:=204070;
NongliData[47]:=3477;
NongliData[48]:=461653;
NongliData[49]:=1386;
NongliData[50]:=2413;
NongliData[51]:=330077;
NongliData[52]:=1197;
NongliData[53]:=2637;
NongliData[54]:=268877;
NongliData[55]:=3365;
NongliData[56]:=531109;
NongliData[57]:=2900;
NongliData[58]:=2922;
NongliData[59]:=398042;
NongliData[60]:=2395;
NongliData[61]:=1179;
NongliData[62]:=267415;
NongliData[63]:=2635;
NongliData[64]:=661067;
NongliData[65]:=1701;
NongliData[66]:=1748;
NongliData[67]:=398772;
NongliData[68]:=2742;
NongliData[69]:=2391;
NongliData[70]:=330031;
NongliData[71]:=1175;
NongliData[72]:=1611;
NongliData[73]:=200010;
NongliData[74]:=3749;
NongliData[75]:=527717;
NongliData[76]:=1452;
NongliData[77]:=2742;
NongliData[78]:=332397;
NongliData[79]:=2350;
NongliData[80]:=3222;
NongliData[81]:=268949;
NongliData[82]:=3402;
NongliData[83]:=3493;
NongliData[84]:=133973;
NongliData[85]:=1386;
NongliData[86]:=464219;
NongliData[87]:=605;
NongliData[88]:=2349;
NongliData[89]:=334123;
NongliData[90]:=2709;
NongliData[91]:=2890;
NongliData[92]:=267946;
NongliData[93]:=2773;
NongliData[94]:=592565;
NongliData[95]:=1210;
NongliData[96]:=2651;
NongliData[97]:=395863;
NongliData[98]:=1323;
NongliData[99]:=2707;
NongliData[100]:=265877;

//得到 数字 年 月 日
curYear  := DATE2DMY(iptDate,3);
curMonth := DATE2DMY(iptDate,2);
curDay   := DATE2DMY(iptDate,1);

//计算到初始时间1921年2月8日的天数:1921-2-8(正月初一)
TheDate := (curYear – 1921) * 365 + INT((curYear – 1921) / 4) + curDay + MonthAdd[curMonth] – 38;
IF ((curYear MOD 4) = 0) AND (curMonth > 2) THEN TheDate := TheDate + 1;

//计算农历天干、地支、月、日
isEnd := 0;
m := 0;
Continue:=TRUE;
WHILE (Continue) DO BEGIN
        IF (NongliData[m+1] < 4095) THEN
                k := 11
        ELSE
                k := 12;
        n := k;
        Continue2:=TRUE;
        WHILE (Continue2) DO BEGIN
           IF (n < 0) THEN
              Continue2:=FALSE
          ELSE BEGIN
            bit := NongliData[m+1];
            FOR i := 1 TO n DO
                    bit := INT(bit / 2);

            bit := bit MOD 2;
            IF (TheDate <= 29 + bit) THEN BEGIN
                    isEnd := 1;
                    Continue2:=FALSE;
            END
            ELSE
              TheDate := TheDate – 29 – bit;
            n := n – 1;
          END;
      END;
    IF (isEnd = 1) THEN
        Continue:=FALSE
    ELSE
      m := m + 1;
END;

curYear := 1921 + m;
curMonth := k – n + 1;
curDay := TheDate;

IF (k = 12) THEN
  IF (curMonth = (INT(NongliData[m+1] / 65536) + 1)) THEN
    curMonth := 1 – curMonth
  ELSE IF (curMonth > (INT(NongliData[m+1] / 65536) + 1)) THEN
    curMonth := curMonth – 1;

//生成农历天干、地支、属相   ==>   NongliStr
  NongliStr := TianGan[1+(((curYear – 4) MOD 60) MOD 10)] + dizhi[1+((curYear – 4) MOD 60) MOD 12] + ‘年’;
  sxStr := ‘(‘+ShuXiang[1+((curYear – 4) MOD 60) MOD 12] + ‘)’;

//生成农历月、日   ==>   NongliDayStr
  IF (curMonth < 1) THEN
    NongliDayStr := ‘闰’ + MonName[-1 * curMonth]
  ELSE
    NongliDayStr := MonName[curMonth];
  NongliDayStr := NongliDayStr + ‘月’;
  NongliDayStr := NongliDayStr + DayName[curDay+1];

CASE Type OF
1:EXIT(NongliStr + sxStr + NongliDayStr);
2:EXIT(NongliStr);
3:EXIT(sxStr);
4:EXIT(NongliDayStr);
END;

分类: C/AL 标签: ,

在SQL Server中处理Navision双字节问题,显示中文

2010年5月21日 没有评论

CREATE FUNCTION dbo.CharConv(@SourceChar Varchar(250))

RETURNS Nvarchar(250)

AS

BEGIN

/* This is create by yeats. */

DECLARE @ReturnChr NVarchar(250)

DECLARE @Process TABLE (Processed VARCHAR(250) COLLATE Chinese_PRC_CI_AS)

INSERT @Process VALUES (CAST(@SourceChar AS VARBINARY(250)))

select @ReturnChr=CAST(Processed AS NVARCHAR(250)) FROM @Process

Return(@ReturnChr)

END;

 

辅助操作语句

select SERVERPROPERTY( ‘Collation ‘) 返回所有的服务器属性

set language N’English’ 设置为English格式

sp_helplanguage 返回所有可以使用的语言

SELECT * FROM ::fn_helpcollations()

得到所有的字符集

分类: Installation 标签: