仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1360|回复: 8
打印 上一主题 下一主题

[学习教程] MSSQL网页编程之一个本人封装的日期工夫操纵的用户工具...

[复制链接]
若相依 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:34:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
在ORDERBY操作中,MySQL只有在排序条件不是一个查询条件表达式的情况下才使用索引。(虽然如此,在涉及多个数据表查询里,即使有索引可用,那些索引在加快ORDERBY方面也没什么作用)。工具|封装
$PBExportHeader$nvo_datetime.sru$PBExportComments$日期工夫操纵类forwardglobaltypenvo_datetimefromnonvisualobjectendtypetypestc_systemtimefromstructurewithinnvo_datetimeendtypeendforwardtypestc_systemtimefromstructureintegerwyearintegerwmonthintegerwdayofweekintegerwdayintegerwhourintegerwminuteintegerwsecondintegerwmillisecondsendtypeglobaltypenvo_datetimefromnonvisualobjectautoinstantiateendtypetypeprototypesFunctionlongSetSystemTime(stc_systemtimelpSystemTime)Library"kernel32.dll"endprototypesforwardprototypespublicfunctionintegerof_getdaysinmonth(datead_date)publicfunctiondateof_getlastdayinmonth(datead_date)publicfunctiondateof_getlastdayinmonth(integerai_year,integerai_month)publicfunctiondateof_getfirstdayinmonth(datead_date)publicfunctiondateof_getfirstdayinmonth(integerai_year,integerai_month)publicfunctionbooleanof_isleapyear(datead_date)publicfunctionbooleanof_isleapyear(integerai_year)publicfunctionbooleanof_lsweekend(datead_date)publicfunctiondateof_skipholidays(datead_date,integerai_increment)publicfunctiondateof_getnextworkday(datawindowadw_holidays,stringas_columnname,datead_date)publicfunctiondateof_getpreviousworkday(datawindowadw_holidays,stringas_columnname,datead_date)publicfunctiondateof_getpreviousworkday(datead_date)publicfunctiondateof_getnextworkday(datead_date)publicfunctiondateof_skipholidays(datastoreads_holidays,stringas_columnname,datead_date,integerai_increment)publicfunctiondateof_skipholidays(datawindowadw_holidays,stringas_columnname,datead_date,integerai_increment)publicfunctiondateof_getnextworkday(datastoreads_holidays,stringas_columnname,datead_date)publicfunctiondateof_getfirstworkday(datawindowadw_holidays,stringas_columnname,datead_date)publicfunctiondateof_getfirstworkday(datastoreads_holidays,stringas_columnname,datead_date)publicfunctiondateof_getpreviousworkday(datastoreads_holidays,stringas_columnname,datead_date)publicfunctiondateof_getfirstworkday(datead_date)publicfunctiondateof_getlastworkday(datastoreads_holidays,stringas_columnname,datead_date)publicfunctiondateof_getlastworkday(datawindowadw_holidays,stringas_columnname,datead_date)publicfunctiondateof_getlastworkday(datead_date)publicfunctionintegerof_getdaysinmonth()publicfunctionintegerof_countdowinmonth(datead_date,integerai_dow)publicfunctionintegerof_countdowinmonth(datead_date)publicfunctionintegerof_countworkdays(datawindowadw_holidays,stringas_columnname,datead_startdate,datead_enddate)publicfunctiondateof_getfirstdayinweek(datead_date)publicfunctiondateof_getlastdayinweek(datead_date)publicfunctiondateof_getfirstdayinmonth()publicfunctiondateof_getlastdayinmonth()publicfunctiondateof_getfirstworkday()publicfunctiondateof_getlastworkday()publicfunctiondateof_getfirstdayinweek()publicfunctiondateof_getlastdayinweek()publicfunctiondateof_getnextworkday()publicfunctiondateof_getpreviousworkday()publicfunctionintegerof_countholidays(datawindowadw_holidays,stringas_columnname,datead_startdate,datead_enddate)publicfunctionintegerof_countholidays(datead_startdate,datead_enddate)publicfunctionintegerof_countholidays(datastoreads_holidays,stringas_columnname,datead_startdate,datead_enddate)publicfunctionintegerof_countworkdays(datastoreads_holidays,stringas_columnname,datead_startdate,datead_enddate)publicfunctionintegerof_countworkdays(datead_startdate,datead_enddate)publicfunctionintegerof_getage(datead_brithday,datead_date)publicfunctionlongof_yearsafter(datead_start,datead_end)publicfunctionlongof_monthsafter(datead_start,datead_end)publicfunctionlongof_weeksafter(datead_start,datead_end)publicfunctionlongof_secondsafter(datetimeadtm_start,datetimeadtm_end)publicfunctionlongof_millisecsafter(timeatm_start,timeatm_end)publicfunctiondateof_relativemonth(datead_source,integeral_month)publicfunctiondatetimeof_relativedatetime(datetimeadtm_start,integeral_offset)publicfunctionintegerof_getquarter(datead_source)publicfunctionintegerof_getquarter()publicfunctiondateof_getfirstdayinquarter(datead_date)publicfunctiondateof_getfirstdayinquarter()publicfunctiondateof_getlastdayinquarter(datead_date)publicfunctiondateof_getlastdayinquarter()publicfunctionlongof_countweeksinyear(datead_source)publicfunctionintegerof_getdayinweek(datead_source)publicfunctiondateof_getfirstdayinyear(datead_date)publicfunctiondateof_getfirstdayinyear()publicfunctiondateof_getfirstdayinyear(integerai_year)publicfunctiondateof_getlastdayinyear(datead_date)publicfunctiondateof_getlastdayinyear()publicfunctiondateof_getlastdayinyear(integerai_year)publicfunctionintegerof_countyeardays(datead_date)publicfunctionintegerof_countyeardays()publicfunctionintegerof_countyeardays(integerai_year)publicfunctionstringof_getconstellation(datead_date)publicfunctionstringof_getgenus(integerai_year)publicfunctionstringof_convertdayoflunar(datead_date)publicfunctiondatetimeof_relativedatetime(datetimead_datetime,longal_number,stringas_kind)publicfunctionstringof_gettgdz(integerai_year)publicfunctionstringof_gettgdz(datead_date)publicfunctionstringof_gettgdz()publicfunctionbooleanof_isleapyear()publicfunctionstringof_getgenus(datead_date)publicfunctionstringof_getgenus()publicfunctionintegerof_countdowinmonth()publicfunctionintegerof_getage(datead_brithday)publicfunctionintegerof_countdowinmonth(integerai_dow)publicfunctionlongof_countweeksinyear()publicfunctionbooleanof_setsystemtime(datetimeadt_datetime)endprototypespublicfunctionintegerof_getdaysinmonth(datead_date);/*函数功效:猎取指定日期地点月份的天数前往值:integer指定日期地点月份的天数参数:ad_datedate日期*/returninteger(28+integer(mid(3+string(abs(sign(mod(sign(mod(abs(year(ad_date)),4))+sign(mod(abs(year(ad_date)),100))+sign(mod(abs(year(ad_date)),400)),2))-1))+3232332323,month(ad_date),1)))endfunctionpublicfunctiondateof_getlastdayinmonth(datead_date);/*函数功效:猎取指定日期地点月份的最初一天前往值:date指定日期地点月份的最初一天参数:ad_datedate日期*/returndate(year(ad_date),month(ad_date),integer(28+integer(mid(3+string(abs(sign(mod(sign(mod(abs(year(ad_date)),4))+sign(mod(abs(year(ad_date)),100))+sign(mod(abs(year(ad_date)),400)),2))-1))+3232332323,month(ad_date),1))))endfunctionpublicfunctiondateof_getlastdayinmonth(integerai_year,integerai_month);/*函数功效:猎取指定年份,月份的最初一天前往值:date指定年份,月份的最初一天参数:integerai_year年份integerai_month月份*/dateld_dateld_date=date(ai_year,ai_month,1)returndate(year(ld_date),month(ld_date),integer(28+integer(mid(3+string(abs(sign(mod(sign(mod(abs(year(ld_date)),4))+sign(mod(abs(year(ld_date)),100))+sign(mod(abs(year(ld_date)),400)),2))-1))+3232332323,month(ld_date),1))))endfunctionpublicfunctiondateof_getfirstdayinmonth(datead_date);/*函数功效:猎取指定日期地点月份的第一天前往值:date指定日期地点月份的第一天参数:datead_date日期*/returndate(year(ad_date),month(ad_date),1)endfunctionpublicfunctiondateof_getfirstdayinmonth(integerai_year,integerai_month);/*函数功效:猎取指定年份,月份的第一天前往值:date指定年份,月份的第一天参数:integerai_year年份integerai_month月份*/returndate(ai_year,ai_month,1)endfunctionpublicfunctionbooleanof_isleapyear(datead_date);/*函数功效:猎取指定日期地点年份是不是为闰年前往值:boolean指定日期地点年份是不是为闰年,true为是闰年,false为闰年参数:ad_datedate日期*/integerli_yearli_year=year(ad_date)returnabs(sign(mod(sign(mod(abs(li_year),4))+sign(mod(abs(li_year),100))+sign(mod(abs(li_year),400)),2))-1)=1endfunctionpublicfunctionbooleanof_isleapyear(integerai_year);/*函数功效:猎取指定年份是不是为闰年前往值:boolean指定年份是不是为闰年,true为是闰年,false为闰年参数:ai_yearinteger年份*/returnabs(sign(mod(sign(mod(abs(ai_year),4))+sign(mod(abs(ai_year),100))+sign(mod(abs(ai_year),400)),2))-1)=1endfunctionpublicfunctionbooleanof_lsweekend(datead_date);/*函数功效:猎取指定日期是不是为周末前往值:date指定日期是不是为周末参数:ad_datedate日期*/stringls_weekls_week=dayname(ad_date)choosecasedayname(ad_date)case"Saturday","Sunday"returntruecaseelsereturnfalseendchooseendfunctionpublicfunctiondateof_skipholidays(datead_date,integerai_increment);/*函数功效:猎取指定日期跳过周末的下一个日期前往值:date前往指定的指定日期跳过周末的下一个日期参数:ad_datedate日期ai_incrementinteger指定的跳过天数*/dateld_dateld_date=ad_datedowhileof_lsweekend(ld_date)=trueld_date=RelativeDate(ld_date,ai_increment)loopreturnld_dateendfunctionpublicfunctiondateof_getnextworkday(datawindowadw_holidays,stringas_columnname,datead_date);/*函数功效:猎取指定日期跳过周末和节沐日的下一个事情日前往值:date前往指定的指定日期跳过周末的下一个事情日参数:adw_holidaysdatawindow存储指定节沐日的数据窗口as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期*/returnof_skipholidays(adw_holidays,as_columnname,RelativeDate(ad_date,1),1)endfunctionpublicfunctiondateof_getpreviousworkday(datawindowadw_holidays,stringas_columnname,datead_date);/*函数功效:猎取指定日期跳过周末和节沐日的上一个事情日前往值:date前往指定的指定日期跳过周末的上一个事情日参数:adw_holidaysdatawindow存储指定节沐日的数据窗口as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期*/returnof_skipholidays(adw_holidays,as_columnname,RelativeDate(ad_date,-1),-1)endfunctionpublicfunctiondateof_getpreviousworkday(datead_date);/*函数功效:猎取指定日期跳过周末的上一个事情日前往值:date前往指定的指定日期跳过周末的上一个事情日参数:ad_datedate日期*/returnof_skipholidays(RelativeDate(ad_date,-1),-1)endfunctionpublicfunctiondateof_getnextworkday(datead_date);/*函数功效:猎取指定日期跳过周末的下一个事情日前往值:date前往指定的指定日期跳过周末的下一个事情日参数:ad_datedate日期*/returnof_skipholidays(RelativeDate(ad_date,1),1)endfunctionpublicfunctiondateof_skipholidays(datastoreads_holidays,stringas_columnname,datead_date,integerai_increment);/*函数功效:猎取指定日期跳过周末和节沐日的下一个日期前往值:date前往指定的指定日期跳过周末和节沐日的下一个日期参数:adw_holidaysdatastore存储指定节沐日的数据存储工具as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期ai_incrementinteger指定的跳过天数*/dateld_dateld_date=ad_datedowhileof_lsweekend(ld_date)=trueorads_holidays.find("string("+as_columnname+",yyyy-mm-dd)"+"="+string(ld_date,"yyyy-mm-dd")+"",1,ads_holidays.rowcount())0ld_date=RelativeDate(ld_date,ai_increment)loopreturnld_dateendfunctionpublicfunctiondateof_skipholidays(datawindowadw_holidays,stringas_columnname,datead_date,integerai_increment);/*函数功效:猎取指定日期跳过周末和节沐日的下一个日期前往值:date前往指定的指定日期跳过周末和节沐日的下一个日期参数:adw_holidaysdatawindow存储指定节沐日的数据窗口as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期ai_incrementinteger指定的跳过天数*/dateld_dateld_date=ad_datedowhileof_lsweekend(ld_date)=trueoradw_holidays.find("string("+as_columnname+",yyyy-mm-dd)"+"="+string(ld_date,"yyyy-mm-dd")+"",1,adw_holidays.rowcount())0ld_date=RelativeDate(ld_date,ai_increment)loopreturnld_dateendfunctionpublicfunctiondateof_getnextworkday(datastoreads_holidays,stringas_columnname,datead_date);/*函数功效:猎取指定日期跳过周末和节沐日的下一个事情日前往值:date前往指定的指定日期跳过周末的下一个事情日参数:ads_holidaysdatastore存储指定节沐日的数据存储工具as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期*/returnof_skipholidays(ads_holidays,as_columnname,RelativeDate(ad_date,1),1)endfunctionpublicfunctiondateof_getfirstworkday(datawindowadw_holidays,stringas_columnname,datead_date);/*函数功效:猎取指定日期地点月的第一个事情日前往值:date前往指定日期地点月的第一个事情日参数:adw_holidaysdatawindow存储指定节沐日的数据存储工具as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期*/dated_tempd_temp=date(year(ad_date),month(ad_date),1)returnof_skipholidays(adw_holidays,as_columnname,d_temp,1)endfunctionpublicfunctiondateof_getfirstworkday(datastoreads_holidays,stringas_columnname,datead_date);/*函数功效:猎取指定日期地点月的第一个事情日前往值:date前往指定日期地点月的第一个事情日参数:ads_holidaysdatastore存储指定节沐日的数据存储工具as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期*/dated_tempd_temp=date(year(ad_date),month(ad_date),1)returnof_skipholidays(ads_holidays,as_columnname,d_temp,1)endfunctionpublicfunctiondateof_getpreviousworkday(datastoreads_holidays,stringas_columnname,datead_date);/*函数功效:猎取指定日期跳过周末和节沐日的上一个事情日前往值:date前往指定的指定日期跳过周末的上一个事情日参数:ads_holidaysdatastore存储指定节沐日的数据存储工具as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期*/returnof_skipholidays(ads_holidays,as_columnname,RelativeDate(ad_date,-1),-1)endfunctionpublicfunctiondateof_getfirstworkday(datead_date);/*函数功效:猎取指定日期地点月的第一个事情日前往值:date前往指定日期地点月的第一个事情日参数:ad_datedate日期*/dated_tempd_temp=date(year(ad_date),month(ad_date),1)returnof_skipholidays(d_temp,1)endfunctionpublicfunctiondateof_getlastworkday(datastoreads_holidays,stringas_columnname,datead_date);/*函数功效:猎取指定日期地点月的最初一个事情日前往值:date前往指定日期地点月的最初一个事情日参数:ads_holidaysdatastore存储指定节沐日的数据存储工具as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期*/dated_tempd_temp=of_getlastdayinmonth(ad_date)returnof_skipholidays(ads_holidays,as_columnname,d_temp,-1)endfunctionpublicfunctiondateof_getlastworkday(datawindowadw_holidays,stringas_columnname,datead_date);/*函数功效:猎取指定日期地点月的最初一个事情日前往值:date前往指定日期地点月的最初一个事情日参数:adw_holidaysdatawindow存储指定节沐日的数据窗口as_columnnamestring数据窗口中存储节沐日的列名ad_datedate日期*/dated_tempd_temp=of_getlastdayinmonth(ad_date)returnof_skipholidays(adw_holidays,as_columnname,d_temp,-1)endfunctionpublicfunctiondateof_getlastworkday(datead_date);/*函数功效:猎取指定日期地点月的最初一个事情日前往值:date前往指定日期地点月的最初一个事情日参数:ad_datedate日期*/dated_tempd_temp=of_getlastdayinmonth(ad_date)returnof_skipholidays(d_temp,-1)endfunctionpublicfunctionintegerof_getdaysinmonth();/*函数功效:猎取指定日期地点月份的天数前往值:integer指定日期地点月份的天数参数:ad_datedate日期*/returninteger(28+integer(mid(3+string(abs(sign(mod(sign(mod(abs(year(today())),4))+sign(mod(abs(year(today())),100))+sign(mod(abs(year(today())),400)),2))-1))+3232332323,month(today()),1)))endfunctionpublicfunctionintegerof_countdowinmonth(datead_date,integerai_dow);/*函数功效:猎取指定日期地点月份的指定礼拜几的天数前往值:integer指定日期地点月份的指定礼拜几的天数参数:ad_datedate日期ai_dowinteger指定的礼拜几1代表礼拜天......7代表礼拜六*/dated_firstintegerintcount,intmonthif(ai_dow<1orai_dow>7)thenai_dow=daynumber(ad_date)endifintmonth=month(ad_date)d_first=date(year(ad_date),month(ad_date),1)dowhiledaynumber(d_first)ai_dowd_first=relativedate(d_first,1)loopintcount=0dowhilemonth(d_first)=intmonthintcount=intcount+1d_first=relativedate(d_first,7)loopreturnintcountendfunctionpublicfunctionintegerof_countdowinmonth(datead_date);/*函数功效:猎取指定日期地点月份的礼拜一的天数前往值:integer指定日期地点月份的礼拜一的天数参数:ad_datedate日期*/returnof_countdowinmonth(ad_date,2)endfunctionpublicfunctionintegerof_countworkdays(datawindowadw_holidays,stringas_columnname,datead_startdate,datead_enddate);/*函数功效:猎取指定日期之间的事情日天数前往值:事情日天数参数:adw_holidaysdatawindow存储指定节沐日的数据窗口as_columnnamestring数据窗口中存储节沐日的列名ad_startdatedate入手下手日期ad_enddatedate停止日期*/integerintdays,li_returndated_tempintegerintsubstractifad_enddate<ad_startdatethend_temp=ad_startdatead_enddate=ad_startdatead_startdate=d_tempendifad_startdate=of_skipholidays(adw_holidays,as_columnname,ad_startdate,1)ad_enddate=of_skipholidays(adw_holidays,as_columnname,ad_enddate,-1)ifad_startdate>ad_enddatethenli_return=0elseintdays=DaysAfter(ad_startdate,ad_enddate)+1intsubstract=intsubstract+of_countholidays(adw_holidays,as_columnname,ad_startdate,ad_enddate)endifli_return=intdays-intsubstractreturnli_returnendfunctionpublicfunctiondateof_getfirstdayinweek(datead_date);/*函数功效:猎取指定日期地点周的第一天前往值:date前往指定日期地点周的第一天参数:ad_datedate日期*/dateld_returnld_return=RelativeDate(ad_date,1-daynumber(ad_date))returnld_returnendfunctionpublicfunctiondateof_getlastdayinweek(datead_date);/*函数功效:猎取指定日期地点周的最初一天前往值:date前往指定日期地点周的最初一天参数:ad_datedate日期*/dateld_returnld_return=RelativeDate(ad_date,7-daynumber(ad_date))returnld_returnendfunctionpublicfunctiondateof_getfirstdayinmonth();/*函数功效:猎取以后日期地点月份的第一天前往值:date以后日期地点月份的第一天参数:datead_date日期*/returndate(year(today()),month(today()),1)endfunctionpublicfunctiondateof_getlastdayinmonth();/*函数功效:猎取以后日期地点月份的最初一天前往值:date以后日期地点月份的最初一天*/returndate(year(today()),month(today()),integer(28+integer(mid(3+string(abs(sign(mod(sign(mod(abs(year(today())),4))+sign(mod(abs(year(today())),100))+sign(mod(abs(year(today())),400)),2))-1))+3232332323,month(today()),1))))endfunctionpublicfunctiondateof_getfirstworkday();/*函数功效:猎取以后日期地点月的第一个事情日前往值:date前往以后日期地点月的第一个事情日*/dated_tempd_temp=date(year(today()),month(today()),1)returnof_skipholidays(d_temp,1)endfunctionpublicfunctiondateof_getlastworkday();/*函数功效:猎取以后日期地点月的最初一个事情日前往值:date前往以后日期地点月的最初一个事情日*/dated_tempd_temp=of_getlastdayinmonth(today())returnof_skipholidays(d_temp,-1)endfunctionpublicfunctiondateof_getfirstdayinweek();/*函数功效:猎取以后日期地点周的第一天前往值:date前往以后日期地点周的第一天参数:ad_datedate日期*/dateld_returnld_return=RelativeDate(today(),1-daynumber(today()))returnld_returnendfunctionpublicfunctiondateof_getlastdayinweek();/*函数功效:猎取指定日期地点周的最初一天前往值:date前往指定日期地点周的最初一天*/dateld_returnld_return=RelativeDate(today(),7-daynumber(today()))returnld_returnendfunctionpublicfunctiondateof_getnextworkday();/*函数功效:猎取以后日期跳过周末的下一个事情日前往值:date前往以后的指定日期跳过周末的下一个事情日*/returnof_skipholidays(RelativeDate(today(),1),1)endfunctionpublicfunctiondateof_getpreviousworkday();/*函数功效:猎取以后日期跳过周末的上一个事情日前往值:date前往以后日期跳过周末的上一个事情日*/returnof_skipholidays(RelativeDate(today(),-1),-1)endfunctionpublicfunctionintegerof_countholidays(datawindowadw_holidays,stringas_columnname,datead_startdate,datead_enddate);/*函数功效:猎取指定日期之间的节沐日天数前往值:节沐日天数参数:adw_holidaysdatawindow存储指定节沐日的数据窗口as_columnnamestring数据窗口中存储节沐日的列名ad_startdatedate入手下手日期ad_enddatedate停止日期*/integerli_returndateld_dateld_date=ad_startdatedowhileld_date<=ad_enddateifof_lsweekend(ld_date)=trueoradw_holidays.find("string("+as_columnname+",yyyy-mm-dd)"+"="+string(ld_date,"yyyy-mm-dd")+"",1,adw_holidays.rowcount())=0thenli_return++endifld_date=relativedate(ld_date,1)loopreturnli_returnendfunctionpublicfunctionintegerof_countholidays(datead_startdate,datead_enddate);/*函数功效:猎取指定日期之间的节沐日天数前往值:节沐日天数参数:ad_startdatedate入手下手日期ad_enddatedate停止日期*/integerli_returndateld_dateld_date=ad_startdatedowhileld_date<=ad_enddateifof_lsweekend(ld_date)=truethenli_return++endifld_date=relativedate(ld_date,1)loopreturnli_returnendfunctionpublicfunctionintegerof_countholidays(datastoreads_holidays,stringas_columnname,datead_startdate,datead_enddate);/*函数功效:猎取指定日期之间的节沐日天数前往值:节沐日天数参数:ads_holidaysdatastore存储指定节沐日的数据存储工具as_columnnamestring数据窗口中存储节沐日的列名ad_startdatedate入手下手日期ad_enddatedate停止日期*/integerli_returndateld_dateld_date=ad_startdatedowhileld_date<=ad_enddateifof_lsweekend(ld_date)=trueorads_holidays.find("string("+as_columnname+",yyyy-mm-dd)"+"="+string(ld_date,"yyyy-mm-dd")+"",1,ads_holidays.rowcount())=0thenli_return++endifld_date=relativedate(ld_date,1)loopreturnli_returnendfunctionpublicfunctionintegerof_countworkdays(datastoreads_holidays,stringas_columnname,datead_startdate,datead_enddate);/*函数功效:猎取指定日期之间的事情日天数前往值:事情日天数参数:ads_holidaysdatastroe存储指定节沐日的数据存储工具as_columnnamestring数据窗口中存储节沐日的列名ad_startdatedate入手下手日期ad_enddatedate停止日期*/integerintdays,li_returndated_tempintegerintsubstractifad_enddate<ad_startdatethend_temp=ad_startdatead_enddate=ad_startdatead_startdate=d_tempendifad_startdate=of_skipholidays(ads_holidays,as_columnname,ad_startdate,1)ad_enddate=of_skipholidays(ads_holidays,as_columnname,ad_enddate,-1)ifad_startdate>ad_enddatethenli_return=0elseintdays=DaysAfter(ad_startdate,ad_enddate)+1intsubstract=intsubstract+of_countholidays(ads_holidays,as_columnname,ad_startdate,ad_enddate)endifli_return=intdays-intsubstractreturnli_returnendfunctionpublicfunctionintegerof_countworkdays(datead_startdate,datead_enddate);/*函数功效:猎取指定日期之间的事情日天数前往值:事情日天数参数:ad_startdatedate入手下手日期ad_enddatedate停止日期*/integerintdays,li_returndated_tempintegerintsubstractifad_enddate<ad_startdatethend_temp=ad_startdatead_enddate=ad_startdatead_startdate=d_tempendifad_startdate=of_skipholidays(ad_startdate,1)ad_enddate=of_skipholidays(ad_enddate,-1)ifad_startdate>ad_enddatethenli_return=0elseintdays=DaysAfter(ad_startdate,ad_enddate)+1intsubstract=intsubstract+of_countholidays(ad_startdate,ad_enddate)endifli_return=intdays-intsubstractreturnli_returnendfunctionpublicfunctionintegerof_getage(datead_brithday,datead_date);/*函数感化:猎取指定诞辰到指定日期的年事函数前往值:integer指定诞辰到指定日期的年事参数:datead_brithday出身日期datead_date指定日期*/integerli_agedateld_tempifad_brithday>ad_datethenld_temp=ad_brithdayad_brithday=ad_datead_date=ld_tempendifli_age=of_yearsafter(ad_brithday,ad_date)ifad_date<date(year(ad_date),month(ad_brithday),day(ad_brithday))thenli_age=li_age-1endifreturnli_ageendfunctionpublicfunctionlongof_yearsafter(datead_start,datead_end);/*函数用处:猎取指定日期之间的相差年度前往值:long相差年度参数:datead_start入手下手日期datead_end停止日期*/dateld_tempintli_year,li_multdoubleadb_start,adb_endIfIsNull(ad_start)orIsNull(ad_end)Thenlongll_nullSetNull(ll_null)Returnll_nullEndIfIfad_start>ad_endThenld_temp=ad_startad_start=ad_endad_end=ld_templi_mult=-1elseli_mult=1EndIfli_year=year(ad_end)-year(ad_start)adb_start=month(ad_start)adb_start=adb_start+day(ad_start)/100adb_end=month(ad_end)adb_end=adb_end+day(ad_end)/100Ifadb_start>adb_endThenli_year--EndIfReturnli_year*li_multendfunctionpublicfunctionlongof_monthsafter(datead_start,datead_end);/*形貌:两个日期之间的月份距离前往:两个日期之间的月份距离参数:datead_start入手下手日期datead_end停止日期*/dateld_tempintegerli_monthintegerli_multIfIsNull(ad_start)orIsNull(ad_end)Thenlongll_nullSetNull(ll_null)Returnll_nullEndIfIfad_start>ad_endThenld_temp=ad_startad_start=ad_endad_end=ld_templi_mult=-1elseli_mult=1EndIfli_month=(year(ad_end)-year(ad_start))*12li_month=li_month+month(ad_end)-month(ad_start)Ifday(ad_start)>day(ad_end)Thenli_month--EndIfReturnli_month*li_multendfunctionpublicfunctionlongof_weeksafter(datead_start,datead_end);/*函数用处:猎取指定日期之间的相差礼拜数前往值:long相差礼拜数参数:datead_start入手下手日期datead_end停止日期*/IfIsNull(ad_start)orIsNull(ad_end)Thenlongll_nullSetNull(ll_null)Returnll_nullEndIfReturnDaysafter(ad_start,ad_end)/7endfunctionpublicfunctionlongof_secondsafter(datetimeadtm_start,datetimeadtm_end);/*函数用处:猎取指定日期之间的相差分钟数前往值:long相差分钟数参数:datetimeadtm_start入手下手工夫datetimeadtm_end停止工夫*/longll_total_seconds,ll_day_adjustdateld_sdate,ld_edatetimelt_stime,lt_etimeIfIsNull(adtm_start)orIsNull(adtm_end)Thenlongll_nullSetNull(ll_null)Returnll_nullEndIfld_sdate=date(adtm_start)ld_edate=date(adtm_end)lt_stime=time(adtm_start)lt_etime=time(adtm_end)Ifld_sdate=ld_edatethenll_total_seconds=secondsafter(lt_stime,lt_etime)Elseifld_sdate<ld_edateThenll_total_seconds=SecondsAfter(lt_stime,Time(23:59:59))ll_day_adjust=DaysAfter(ld_sdate,ld_edate)-1Ifll_day_adjust>0Thenll_total_seconds=ll_total_seconds+86400*ll_day_adjustll_total_seconds=ll_total_seconds+SecondsAfter(Time(00:00:00),lt_etime)+1Elsell_total_seconds=SecondsAfter(lt_stime,Time(00:00:00))ll_day_adjust=DaysAfter(ld_sdate,ld_edate)+1Ifll_day_adjust<0Thenll_total_seconds=ll_total_seconds+86400*ll_day_adjustll_total_seconds=ll_total_seconds+SecondsAfter(Time(23:59:59),lt_etime)-1endIfreturnll_total_secondsendfunctionpublicfunctionlongof_millisecsafter(timeatm_start,timeatm_end);/*函数用处:猎取指准时间之间的相差秒数前往值:long相差相差秒数参数:timeatm_start入手下手工夫timeatm_end停止工夫*/Longll_start,ll_endLongll_tempIfIsNull(atm_start)orIsNull(atm_end)Thenlongll_nullSetNull(ll_null)Returnll_nullEndIfll_start=Long(String(atm_start,"fff"))ll_temp=Second(atm_start)*1000ll_start=ll_start+ll_templl_temp=Minute(atm_start)*60000ll_start=ll_start+ll_templl_temp=hour(atm_start)*3600000ll_start=ll_start+ll_templl_end=Long(String(atm_end,"fff"))ll_temp=Second(atm_end)*1000ll_end=ll_end+ll_templl_temp=minute(atm_end)*60000ll_end=ll_end+ll_templl_temp=hour(atm_end)*3600000ll_end=ll_end+ll_tempreturnll_end-ll_startendfunctionpublicfunctiondateof_relativemonth(datead_source,integeral_month);/*函数功效:前往指定日期相差指定月份后的日期前往值:date指定日期相差指定月份后的日期参数:datead_source初始日期integeral_month月数*/integerli_adjust_months,li_adjust_yearsintegerli_month,li_year,li_dayintegerli_temp_monthIfIsNull(ad_source)orIsNull(al_month)Thendateldt_nullSetNull(ldt_null)Returnldt_nullEndIfli_adjust_months=mod(al_month,12)li_adjust_years=(al_month/12)li_temp_month=Month(ad_source)+li_adjust_monthsIfli_temp_month>12Thenli_month=li_temp_month-12li_adjust_years++ElseIfli_temp_month<=0Thenli_month=li_temp_month+12li_adjust_years--Elseli_month=li_temp_monthEndIfli_year=Year(ad_source)+li_adjust_yearsli_day=Day(ad_source)DoWhileli_day>0li_day--LoopDateld_Retld_Ret=Date(li_year,li_month,li_day)Returnld_Retendfunctionpublicfunctiondatetimeof_relativedatetime(datetimeadtm_start,integeral_offset);/*函数功效:前往指准时间相差指定秒数后的工夫前往值:datetime指准时间相差指定秒数后的工夫参数:datetimeadtm_start初始工夫integeral_month秒数*/datetimeldt_nulldateld_sdatetimelt_stimelongll_date_adjustlongll_time_adjust,ll_time_testIfIsNull(adtm_start)orIsNull(al_offset)ThenSetNull(ldt_null)Returnldt_nullEndIfld_sdate=date(adtm_start)lt_stime=time(adtm_start)ll_date_adjust=al_offset/86400ll_time_adjust=mod(al_offset,86400)ld_sdate=RelativeDate(ld_sdate,ll_date_adjust)Ifll_time_adjust>0thenll_time_test=SecondsAfter(lt_stime,time(23:59:59))Ifll_time_test<ll_time_adjustThenld_sdate=RelativeDate(ld_sdate,1)ll_time_adjust=ll_time_adjust-ll_time_test-1lt_stime=time(00:00:00)EndIflt_stime=RelativeTime(lt_stime,ll_time_adjust)ElseIfll_time_adjust<0thenll_time_test=SecondsAfter(lt_stime,time(00:00:00))Ifll_time_test>ll_time_adjustThenld_sdate=RelativeDate(ld_sdate,-1)ll_time_adjust=ll_time_adjust-ll_time_test+1lt_stime=time(23:59:59)EndIflt_stime=RelativeTime(lt_stime,ll_time_adjust)EndIfreturn(datetime(ld_sdate,lt_stime))endfunctionpublicfunctionintegerof_getquarter(datead_source);/*函数功效:取得指定日期地点的季度前往值:integer指定日期地点的季度参数:datead_source日期*/IFIsNull(ad_source)THENLongll_nullSetNull(ll_null)Returnll_nullENDIFIntegerli_Month,li_Quarterli_Month=Month(ad_Source)li_Quarter=(li_Month-1)/3Returnli_Quarterendfunctionpublicfunctionintegerof_getquarter();/*函数功效:取得以后日期地点的季度前往值:integer以后日期地点的季度*/Integerli_Month,li_Quarterli_Month=Month(today())li_Quarter=(li_Month-1)/3Returnli_Quarterendfunctionpublicfunctiondateof_getfirstdayinquarter(datead_date);/*函数用处:猎取指定日期地点的季度的第一天前往值:date指定日期地点的季度的第一天参数:datead_date指定日期*/dateld_returnconstantintegerli_monthsinquarter=3ld_return=date(year(ad_date),int((month(ad_date)-1)/li_monthsinquarter)*li_monthsinquarter+1,1)returnld_returnendfunctionpublicfunctiondateof_getfirstdayinquarter();/*函数用处:猎取以后日期地点的季度的第一天前往值:date以后日期地点的季度的第一天*/dateld_returnconstantintegerli_monthsinquarter=3ld_return=date(year(today()),int((month(today())-1)/li_monthsinquarter)*li_monthsinquarter+1,1)returnld_returnendfunctionpublicfunctiondateof_getlastdayinquarter(datead_date);/*函数用处:猎取指定日期地点的季度的最初一天前往值:date指定日期地点的季度的最初一天参数:datead_date指定日期*/dateld_returnconstantintegerli_monthsinquarter=3ld_return=date(year(ad_date),int((month(ad_date)-1)/li_monthsinquarter)*li_monthsinquarter+(li_monthsinquarter+1),integer(28+integer(mid(3+string(abs(sign(mod(sign(mod(abs(year(ad_date)),4))+sign(mod(abs(year(ad_date)),100))+sign(mod(abs(year(ad_date)),400)),2))-1))+3232332323,month(ad_date),1))))returnld_returnendfunctionpublicfunctiondateof_getlastdayinquarter();/*函数用处:猎取以后日期地点的季度的最初一天前往值:date以后日期地点的季度的最初一天*/dateld_returnconstantintegerli_monthsinquarter=3ld_return=date(year(today()),int((month(today())-1)/li_monthsinquarter)*li_monthsinquarter+(li_monthsinquarter+1),integer(28+integer(mid(3+string(abs(sign(mod(sign(mod(abs(year(today())),4))+sign(mod(abs(year(today())),100))+sign(mod(abs(year(today())),400)),2))-1))+3232332323,month(today()),1))))returnld_returnendfunctionpublicfunctionlongof_countweeksinyear(datead_source);/*函数用处:猎取指定日期地点年份的礼拜数前往值:long前往日期地点年份的礼拜数参数:datead_source指定日期*/dateld_first_ofyearintegerli_weeknumberintegerli_leftover_daysIfIsNull(ad_source)Thenlongll_nullSetNull(ll_null)Returnll_nullEndIfld_first_ofyear=Date(Year(ad_source),1,1)li_weeknumber=of_WeeksAfter(ld_first_ofyear,ad_source)+1li_leftover_days=Mod(DaysAfter(ld_first_ofyear,ad_source),7)If(of_getdayinweek(ld_first_ofyear)+li_leftover_days)>=8thenli_weeknumber++EndIfReturnli_weeknumberendfunctionpublicfunctionintegerof_getdayinweek(datead_source);//形貌:决意日期是礼拜几,以礼拜天作为一个礼拜的第一天//参数://[value]datead_source<形貌>//前往:(INTEGER)//1-IftheDayisSunday.//2-IftheDayisMonday//3-IftheDayisTuesday.//4-IftheDayisWednesday.//5-IftheDayisThursday.//6-IftheDayisFriday.//7-IftheDayisSaturday.//IfanyargumentsvalueisNULL,functionreturnsNULL.//IfIsNull(ad_source)Thenlongll_nullSetNull(ll_null)Returnll_nullEndIfreturnDayNumber(ad_source)endfunctionpublicfunctiondateof_getfirstdayinyear(datead_date);/*函数功效:猎取指定日期地点年份的第一天前往值:date指定日期地点年份的第一天参数:datead_date日期*/returndate(year(ad_date),1,1)endfunctionpublicfunctiondateof_getfirstdayinyear();/*函数功效:猎取以后日期地点年份的第一天前往值:date以后日期地点年份的第一天参数:datead_date日期*/returndate(year(today()),1,1)endfunctionpublicfunctiondateof_getfirstdayinyear(integerai_year);/*函数功效:猎取指定年份的第一天前往值:date指定年份的第一天参数:datead_date日期*/returndate(ai_year,1,1)endfunctionpublicfunctiondateof_getlastdayinyear(datead_date);/*函数功效:猎取指定日期地点年份的最初一天前往值:date指定日期地点年份的最初一天参数:datead_date日期*/returndate(year(ad_date),12,31)endfunctionpublicfunctiondateof_getlastdayinyear();/*函数功效:猎取以后日期地点年份的最初一天前往值:date以后日期地点年份的最初一天参数:datead_date日期*/returndate(year(today()),12,31)endfunctionpublicfunctiondateof_getlastdayinyear(integerai_year);/*函数功效:猎取指定日期地点年份的最初一天前往值:date指定日期地点年份的最初一天参数:integerai_year年份*/returndate(ai_year,12,31)endfunctionpublicfunctionintegerof_countyeardays(datead_date);/*函数用处:猎取指定日期地点年份的天数函数前往值:integer天数参数:datead_date日期*/returndaysafter(of_getfirstdayinyear(ad_date),of_getlastdayinyear(ad_date))endfunctionpublicfunctionintegerof_countyeardays();/*函数用处:猎取以后日期地点年份的天数函数前往值:integer天数*/returndaysafter(of_getfirstdayinyear(),of_getlastdayinyear())endfunctionpublicfunctionintegerof_countyeardays(integerai_year);/*函数用处:猎取指定年份的天数函数前往值:integer天数参数:integerai_year年份*/returndaysafter(of_getfirstdayinyear(ai_year),of_getlastdayinyear(ai_year))endfunctionpublicfunctionstringof_getconstellation(datead_date);/*函数用处:前往指定日期地点星座前往值:string指定日期地点星座参数:datead_date指定日期*/returnmid("摩羯水瓶双鱼白羊金牛双子巨蟹狮子童贞天秤天蝎弓手摩羯",(month(ad_date)+sign(sign(day(ad_date)-(19+integer(mid(102123444423,month(ad_date),1))))+1))*4-3,4)+座endfunctionpublicfunctionstringof_getgenus(integerai_year);/*函数功效:猎取指定年份的生肖前往值:string前往指定的年份的生肖参数:ai_yearinteger年份*/stringls_returnsetnull(ls_return)ifai_year<1900thenreturnls_returnls_return=mid(fill(鼠牛虎兔龙蛇马羊猴鸡狗猪,48),(mod(ai_year-1900,12)+13)*2-1,2)returnls_returnendfunctionpublicfunctionstringof_convertdayoflunar(datead_date);stringWeekName[0to7],TianGan[0to9],DiZhi[0to11],ShuXiang[0to11],DayName[0to30],MonName[0to12]longMonthAdd[0to11],NongliData[0to99]longcurTime,curYear,curMonth,curDay,curWeekdaystringGongliStr,WeekdayStr,NongliStr,NongliDayStrlongi,m,n,k,isEnd,bit,thedateWeekName[0]="*"WeekName[1]="日曜日"WeekName[2]="礼拜一"WeekName[3]="礼拜二"WeekName[4]="礼拜三"WeekName[5]="木曜日"WeekName[6]="礼拜五"WeekName[7]="礼拜六"//天干称号TianGan[0]="甲"TianGan[1]="乙"TianGan[2]="丙"TianGan[3]="丁"TianGan[4]="戊"TianGan[5]="己"TianGan[6]="庚"TianGan[7]="辛"TianGan[8]="壬"TianGan[9]="癸"//地支称号DiZhi[0]="子"DiZhi[1]="丑"DiZhi[2]="寅"DiZhi[3]="卯"DiZhi[4]="辰"DiZhi[5]="巳"DiZhi[6]="午"DiZhi[7]="未"DiZhi[8]="申"DiZhi[9]="酉"DiZhi[10]="戌"DiZhi[11]="亥"//属相称号ShuXiang[0]="鼠"ShuXiang[1]="牛"ShuXiang[2]="虎"ShuXiang[3]="兔"ShuXiang[4]="龙"ShuXiang[5]="蛇"ShuXiang[6]="马"ShuXiang[7]="羊"ShuXiang[8]="猴"ShuXiang[9]="鸡"ShuXiang[10]="狗"ShuXiang[11]="猪"//夏历日期名DayName[0]="*"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]="三十"//夏历月份名MonName[0]="*"MonName[1]="正"MonName[2]="二"MonName[3]="三"MonName[4]="四"MonName[5]="五"MonName[6]="六"MonName[7]="七"MonName[8]="八"MonName[9]="九"MonName[10]="十"MonName[11]="十一"MonName[12]="腊"//公历每个月后面的天数MonthAdd[0]=0MonthAdd[1]=31MonthAdd[2]=59MonthAdd[3]=90MonthAdd[4]=120MonthAdd[5]=151MonthAdd[6]=181MonthAdd[7]=212MonthAdd[8]=243MonthAdd[9]=273MonthAdd[10]=304MonthAdd[11]=334//夏历数据NongliData[0]=2635NongliData[1]=333387NongliData[2]=1701NongliData[3]=1748NongliData[4]=267701NongliData[5]=694NongliData[6]=2391NongliData[7]=133423NongliData[8]=1175NongliData[9]=396438NongliData[10]=3402NongliData[11]=3749NongliData[12]=331177NongliData[13]=1453NongliData[14]=694NongliData[15]=201326NongliData[16]=2350NongliData[17]=465197NongliData[18]=3221NongliData[19]=3402NongliData[20]=400202NongliData[21]=2901NongliData[22]=1386NongliData[23]=267611NongliData[24]=605NongliData[25]=2349NongliData[26]=137515NongliData[27]=2709NongliData[28]=464533NongliData[29]=1738NongliData[30]=2901NongliData[31]=330421NongliData[32]=1242NongliData[33]=2651NongliData[34]=199255NongliData[35]=1323NongliData[36]=529706NongliData[37]=3733NongliData[38]=1706NongliData[39]=398762NongliData[40]=2741NongliData[41]=1206NongliData[42]=267438NongliData[43]=2647NongliData[44]=1318NongliData[45]=204070NongliData[46]=3477NongliData[47]=461653NongliData[48]=1386NongliData[49]=2413NongliData[50]=330077NongliData[51]=1197NongliData[52]=2637NongliData[53]=268877NongliData[54]=3365NongliData[55]=531109NongliData[56]=2900NongliData[57]=2922NongliData[58]=398042NongliData[59]=2395NongliData[60]=1179NongliData[61]=267415NongliData[62]=2635NongliData[63]=661067NongliData[64]=1701NongliData[65]=1748NongliData[66]=398772NongliData[67]=2742NongliData[68]=2391NongliData[69]=330031NongliData[70]=1175NongliData[71]=1611NongliData[72]=200010NongliData[73]=3749NongliData[74]=527717NongliData[75]=1452NongliData[76]=2742NongliData[77]=332397NongliData[78]=2350NongliData[79]=3222NongliData[80]=268949NongliData[81]=3402NongliData[82]=3493NongliData[83]=133973NongliData[84]=1386NongliData[85]=464219NongliData[86]=605NongliData[87]=2349NongliData[88]=334123NongliData[89]=2709NongliData[90]=2890NongliData[91]=267946NongliData[92]=2773NongliData[93]=592565NongliData[94]=1210NongliData[95]=2651NongliData[96]=395863NongliData[97]=1323NongliData[98]=2707NongliData[99]=265877curYear=Year(ad_date)curMonth=Month(ad_date)curDay=Day(ad_date)GongliStr=string(curYear)+"年"If(curMonth<10)ThenGongliStr=GongliStr+"0"+string(curMonth)+"月"ElseGongliStr=GongliStr+string(curMonth)+"月"EndIfIf(curDay<10)ThenGongliStr=GongliStr+"0"+string(curDay)+"日"ElseGongliStr=GongliStr+string(curDay)+"日"EndIf//天生以后公历礼拜==>WeekdayStrcurWeekday=daynumber(ad_date)WeekdayStr=weekName[curWeekday]//盘算到初始工夫1921年2月8日的天数:1921-2-8(正月月朔)TheDate=(curYear-1921)*365+Int((curYear-1921)/4)+curDay+MonthAdd[curMonth-1]-38If(mod(CurYear,4)=0AndcurMonth>2)ThenTheDate=TheDate+1EndIf//盘算夏历天干、地支、月、日isEnd=0m=0DoIf(NongliData[m]<4095)Thenk=11Elsek=12EndIfn=kDoIf(n<0)ThenExitEndIf//猎取NongliData(m)的第n个二进制位的值bit=NongliData[m]Fori=1TonStep1bit=Int(bit/2)Nextbit=mod(bit,2)If(TheDate<=29+bit)ThenisEnd=1ExitEndIfTheDate=TheDate-29-bitn=n-1loopuntil11If(isEnd=1)ThenExitEndIfm=m+1Loopuntil11curYear=1921+mcurMonth=k-n+1curDay=TheDateIf(k=12)ThenIf(curMonth=(Int(NongliData[m]/65536)+1))ThencurMonth=1-curMonthElseIf(curMonth>(Int(NongliData[m]/65536)+1))ThencurMonth=curMonth-1EndIfEndIf//天生夏历天干、地支、属相==>NongliStrNongliStr="夏历"+TianGan[mod(mod(curYear-4,60),10)]+DiZhi[mod(mod(curYear-4,60),12)]+"年"NongliStr=NongliStr+"("+ShuXiang[mod(mod(curYear-4,60),12)]+")"//天生夏历月、日==>NongliDayStrIf(curMonth<1)ThenNongliDayStr="闰"+MonName[-1*curMonth]ElseNongliDayStr=MonName[curMonth]EndIfNongliDayStr=NongliDayStr+"月"NongliDayStr=NongliDayStr+DayName[curDay]returnnonglistr+nonglidaystrendfunctionpublicfunctiondatetimeof_relativedatetime(datetimead_datetime,longal_number,stringas_kind);//*******************************************************************************//函数名:f_RelativeDataTime(datatimead_datetime,longal_number,stringal_kind)//用途:盘算datatime范例的绝对日期工夫//输进:日期工夫、绝对数目、单元(天、小时、分、秒)//输出:推算后的日期工夫//*******************************************************************************longll_relativesecond,ll_secondtimelt_timedateld_dateconstantlongONEDAYSECOND=86400ld_date=date(ad_datetime)lt_time=time(ad_datetime)choosecaseas_kindcase"天"returndatetime(relativedate(ld_date,al_number),lt_time)case"小时"ll_relativesecond=al_number*3600case"分"ll_relativesecond=al_number*60case"秒"ll_relativesecond=al_numberendchoosell_second=hour(lt_time)*3600+minute(lt_time)*60+second(lt_time)ld_date=relativedate(ld_date,integer(ll_relativesecond/ONEDAYSECOND))ll_relativesecond-=integer(ll_relativesecond/ONEDAYSECOND)*ONEDAYSECONDif(ll_second+ll_relativesecond<0)thenreturndatetime(relativedate(ld_date,-1),relativetime(time("00:00:00:000"),ONEDAYSECOND+ll_second+ll_relativesecond))endifif(ll_second+ll_relativesecond>ONEDAYSECOND)thenreturndatetime(relativedate(ld_date,1),relativetime(time("00:00:00:000"),ll_second+ll_relativesecond-ONEDAYSECOND))endifreturndatetime(ld_date,relativetime(lt_time,ll_relativesecond))endfunctionpublicfunctionstringof_gettgdz(integerai_year);/*函数功效:猎取指定年份的天干地支前往值:string前往指定的年份的天干地支参数:ai_yearinteger年份*/stringls_returnsetnull(ls_return)ifai_year<1924thenreturnls_returnls_return=mid(fill(甲乙丙丁戊己庚辛壬癸,40),(mod(ai_year-1924,10)+11)*2-1,2)+mid(fill(子丑寅卯辰巳午未申酉戌亥,48),(mod(ai_year-1924,12)+13)*2-1,2)returnls_returnendfunctionpublicfunctionstringof_gettgdz(datead_date);/*函数功效:猎取指定日期地点年份的天干地支前往值:string前往指定日期地点年份的天干地支参数:ad_datedate年份*/integeral_yearstringls_returnsetnull(ls_return)al_year=year(ad_date)ifal_year<1924thenreturnls_returnls_return=mid(fill(甲乙丙丁戊己庚辛壬癸,40),(mod(al_year-1924,10)+11)*2-1,2)+mid(fill(子丑寅卯辰巳午未申酉戌亥,48),(mod(al_year-1924,12)+13)*2-1,2)returnls_returnendfunctionpublicfunctionstringof_gettgdz();/*函数功效:猎取以后日期地点年份的天干地支前往值:string前往以后日期地点年份的天干地支*/integeral_yearstringls_returnsetnull(ls_return)al_year=year(today())ifal_year<1924thenreturnls_returnls_return=mid(fill(甲乙丙丁戊己庚辛壬癸,40),(mod(al_year-1924,10)+11)*2-1,2)+mid(fill(子丑寅卯辰巳午未申酉戌亥,48),(mod(al_year-1924,12)+13)*2-1,2)returnls_returnendfunctionpublicfunctionbooleanof_isleapyear();/*函数功效:猎取以后日期地点年份是不是为闰年前往值:boolean以后日期地点年份是不是为闰年,true为是闰年,false为闰年*/integerli_yearli_year=year(today())returnabs(sign(mod(sign(mod(abs(li_year),4))+sign(mod(abs(li_year),100))+sign(mod(abs(li_year),400)),2))-1)=1endfunctionpublicfunctionstringof_getgenus(datead_date);/*函数功效:猎取指定日期地点年份的生肖前往值:string前往指定日期地点年份的生肖参数:ad_datedate日期*/integerli_yearstringls_returnli_year=year(ad_date)setnull(ls_return)ifli_year<1900thenreturnls_returnls_return=mid(fill(鼠牛虎兔龙蛇马羊猴鸡狗猪,48),(mod(li_year-1900,12)+13)*2-1,2)returnls_returnendfunctionpublicfunctionstringof_getgenus();/*函数功效:猎取以后日期地点年份的生肖前往值:string前往以后日期地点年份的生肖*/integerli_yearstringls_returnli_year=year(today())setnull(ls_return)ifli_year<1900thenreturnls_returnls_return=mid(fill(鼠牛虎兔龙蛇马羊猴鸡狗猪,48),(mod(li_year-1900,12)+13)*2-1,2)returnls_returnendfunctionpublicfunctionintegerof_countdowinmonth();/*函数功效:猎取以后日期地点月份的礼拜一的天数前往值:integer以后日期地点月份的礼拜一的天数*/returnof_countdowinmonth(today(),2)endfunctionpublicfunctionintegerof_getage(datead_brithday);/*函数感化:猎取指定诞辰到以后日期的年事函数前往值:integer指定诞辰到以后日期的年事参数:datead_brithday出身日期*/integerli_agedateld_datedateld_templd_date=today()ifad_brithday>ld_datethenld_temp=ad_brithdayad_brithday=ld_dateld_date=ld_tempendifli_age=of_yearsafter(ad_brithday,ld_date)ifld_date<date(year(ld_date),month(ad_brithday),day(ad_brithday))thenli_age=li_age-1endifreturnli_ageendfunctionpublicfunctionintegerof_countdowinmonth(integerai_dow);/*函数功效:猎取以后日期地点月份的指定礼拜几的天数前往值:integer指定以后地点月份的指定礼拜几的天数参数:ai_dowinteger指定的礼拜几1代表礼拜天......7代表礼拜六*/dated_firstintegerintcount,intmonthif(ai_dow<1orai_dow>7)thenai_dow=daynumber(today())endifintmonth=month(today())d_first=date(year(today()),month(today()),1)dowhiledaynumber(d_first)ai_dowd_first=relativedate(d_first,1)loopintcount=0dowhilemonth(d_first)=intmonthintcount=intcount+1d_first=relativedate(d_first,7)loopreturnintcountendfunctionpublicfunctionlongof_countweeksinyear();/*函数用处:猎取以后日期地点年份的礼拜数前往值:long前往以后日期地点年份的礼拜数*/dateld_first_ofyearintegerli_weeknumberintegerli_leftover_daysld_first_ofyear=Date(Year(today()),1,1)li_weeknumber=of_WeeksAfter(ld_first_ofyear,today())+1li_leftover_days=Mod(DaysAfter(ld_first_ofyear,today()),7)If(of_getdayinweek(ld_first_ofyear)+li_leftover_days)>=8thenli_weeknumber++EndIfReturnli_weeknumberendfunctionpublicfunctionbooleanof_setsystemtime(datetimeadt_datetime);stc_systemtimelstc_systemtimedateld_datetimelt_timeld_date=date(adt_datetime)lt_time=time(adt_datetime)lstc_systemtime.wyear=year(ld_date)lstc_systemtime.wmonth=month(ld_date)lstc_systemtime.wday=day(ld_date)lstc_systemtime.wdayofweek=daynumber(ld_date)lstc_systemtime.whour=hour(lt_time)lstc_systemtime.wminute=minute(lt_time)lstc_systemtime.wsecond=minute(lt_time)lstc_systemtime.wmilliseconds=0returnsetsystemtime(lstc_systemtime)0endfunctiononnvo_datetime.createcallsuper::createTriggerEvent(this,"constructor")endononnvo_datetime.destroyTriggerEvent(this,"destructor")callsuper::destroyendoneventconstructor;//**********************************************************////nvo_datetime日期工夫操纵类,自创立不成视用户工具////author:tiantianpb////writedate:2003-11-16////used:对各类经常使用的日期工夫操纵举行了相干的封装////*********************************************************//endevent
优化的SQL查询算法,有效地提高查询速度
海妖 该用户已被删除
沙发
发表于 2015-1-18 16:55:01 | 只看该作者
你觉得我的非分区索引无法对起子分区,你可以提醒我一下呀!没有任何的提醒,直接就变成了非分区表。不知道这算不算一个bug。大家也可以试试。
板凳
发表于 2015-1-22 14:50:31 | 只看该作者
一个是把SQL语句写到客户端,可以使用DataSet进行加工;
冷月葬花魂 该用户已被删除
地板
发表于 2015-1-31 07:18:32 | 只看该作者
另一个是把SQL语句写到服务器端,就是所谓的SP(存储过程);
若相依 该用户已被删除
5#
 楼主| 发表于 2015-2-6 18:24:20 | 只看该作者
连做梦都在想页面结构是怎么样的,绝非虚言
活着的死人 该用户已被删除
6#
发表于 2015-2-18 02:08:55 | 只看该作者
Mirror可以算是SQLServer的Dataguard了。但是能不能被大伙用起来就不知道了。
小魔女 该用户已被删除
7#
发表于 2015-3-6 00:11:52 | 只看该作者
无法深入到数据库系统层面去了解和探究
蒙在股里 该用户已被删除
8#
发表于 2015-3-12 16:39:21 | 只看该作者
个人感觉没有case直观。而且默认的第三字段(还可能更多)作为groupby字段很容易造成新手的错误。
灵魂腐蚀 该用户已被删除
9#
发表于 2015-3-20 00:45:41 | 只看该作者
sqlserver的痛苦之处在于有用文档的匮乏,很多只是表明的东西
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-23 10:30

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表