我是初学的,请问怎么获得日期的年月日

linleming 2004-04-07 09:40:22
想分别得到一个日期变量中的年月日,分别赋给三给字符串变量?
...全文
133 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
koma2003 2004-04-08
  • 打赏
  • 举报
回复
用DecodeDate
linleming 2004-04-08
  • 打赏
  • 举报
回复
谢谢各位,昨天回家试的所以现在才结帖!
hksl 2004-04-07
  • 打赏
  • 举报
回复
可以用这个

procedure Tfrmmain.FormShow(Sender: TObject);
var year,month,day:word;

begin
decodeDate(now,year,month,day);
statusbar1.Panels[2].Text:=inttostr(year)+'年'+ inttostr(month)+'月'+inttostr(day)+'日' ;
end;
lzy6204 2004-04-07
  • 打赏
  • 举报
回复
delphi里面的取日期函数就如楼上几位所说的
要是用SQL语句实现,应该是:
year(),month(),day()
hhzqf1980 2004-04-07
  • 打赏
  • 举报
回复
inttostr(dayof(now));
inttostr(monthof(now));
inttostr(yearof(now));
还有就是别忘了:
uses DateUtils


ziqing 2004-04-07
  • 打赏
  • 举报
回复
说错了,呵呵返回是WORD类型
ziqing 2004-04-07
  • 打赏
  • 举报
回复
dayof(now)
monthof(now)
yearof(now)
返回的都是INTEGER类型
syl79 2004-04-07
  • 打赏
  • 举报
回复
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
sxy_9761 2004-04-07
  • 打赏
  • 举报
回复
uses DateUtils

var
lday,lmonth,lyear : string;
begin
lday := inttostr(dayof(now));
lmonth := inttostr(monthof(now));
lyare := inttostr(yearof(now));
end;

5,391

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧