| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1086 人关注过本帖
标题:关于日期的问题
只看楼主 加入收藏
q19810321
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-5-30
收藏
 问题点数:0 回复次数:2 
关于日期的问题
输入一日期,求该日期是该年中的第几天?
2008-02-26 14:57
思逸
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-2-28
收藏
得分:0 
用该日期直接减这一年的开始日期1月1号.
var date1,date2,Dstart,Dend,Dcount:Tdatetime;
    Dstart:=strtodate('2008-1-1');
    Dend:=date();
    Dcount:=Dend-Dstart;
    edit1.text:=floattostr(Dcount);
2008-02-28 11:32
zhoukai
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-4-11
收藏
得分:0 
我也是新手,看到题目手痒,这是我写的代码,已通过!请大家指教!
procedure TForm1.Button2Click(Sender: TObject);
var
    year1: string;
    year2: integer;
    month1: string;
    month2: integer;
    mont: integer;
    days2: integer;
    days4: integer;
    days1: string;
    days3: integer;
    i: integer;
    mont1,mont2,mont3 : set of 01..12;
begin
mont1:=[01,03,05,07,08,10,12];
mont2:=[04,06,09,11];
mont3:=[02];
days2:=0;
year1:=LeftStr(edit2.Text,4);
month1:=MidStr(edit2.Text,6,2);
days1:=RightStr(edit2.Text,2);
year2:= StrToInt(year1);
month2:=StrToInt(month1);
days3:= StrToInt(days1);
mont:=month2;
for i:= 1 to mont-1 do
begin
   if i in mont1 then  days4:=31
   else
       if  i in mont2  then   days4:=30
       else
           if  i in mont3  then
                 if IsLeapYear(year2)=true then  days4:=29
                else  days4:=28;
    days2:=days2+days4;
end;
  days2:=days2+days3;
  edit3.Text:=edit2.Text;
  edit4.Text:=IntToStr(days2);
end;
2008-04-18 08:24
快速回复:关于日期的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011219 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved