G gougou Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-06 #1 如何把一个日期时间型变量转换成一个日期型变量和一个时间型变量?
C cx139 Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-06 #2 不太明白,如果是一个转化为一个,就用DELPHI中的函数就OK了,<br>但你如果想把2001-12-30 12:00 转化为一个2001-12-30和一个12:00<br>那……<br>只有一歪招,先把TDateTimeZ转换为字符串,然后截取成两段,再把两个字符形<br>转化为DATE和TIME了
不太明白,如果是一个转化为一个,就用DELPHI中的函数就OK了,<br>但你如果想把2001-12-30 12:00 转化为一个2001-12-30和一个12:00<br>那……<br>只有一歪招,先把TDateTimeZ转换为字符串,然后截取成两段,再把两个字符形<br>转化为DATE和TIME了
G gougou Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-06 #3 把2001-12-30 12:00转换成2001-12-30
B black猫 Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-07 #5 Tdate,TTime,Tdatetime都是Double类型,<br>mytdate:=int(mytdatetime);<br>myttime:=mytdatetime-int(mytdatetime);<br>
Tdate,TTime,Tdatetime都是Double类型,<br>mytdate:=int(mytdatetime);<br>myttime:=mytdatetime-int(mytdatetime);<br>
H hding Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-07 #6 []<br>var<br>Dt:TDatetime;<br>Day,Time:string;<br>begin<br> Day:=DateToStr(DT);<br> Time:=TimeToStr(DT);<br>//或者<br> Day=formatDatetimetoStr('yyyy/mm/dd',DT);<br> Time:=formatDatetimetoStr('hh:mm:ss',DT);<br>end;<br>其它格式转换,参看Help.
[]<br>var<br>Dt:TDatetime;<br>Day,Time:string;<br>begin<br> Day:=DateToStr(DT);<br> Time:=TimeToStr(DT);<br>//或者<br> Day=formatDatetimetoStr('yyyy/mm/dd',DT);<br> Time:=formatDatetimetoStr('hh:mm:ss',DT);<br>end;<br>其它格式转换,参看Help.
H HammerLi Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-07 #7 先DecodeDateTime<br>再EncodeDate<br>再EncodeTime
Z zhukewen Unregistered / Unconfirmed GUEST, unregistred user! 2002-01-07 #8 正确而简单的做法是:<br>var d : TDate; t:TTime; dt : TDateTime;<br>begin<br> dt := now;<br> d := TDate(dt);<br> t := TTime(dt);
正确而简单的做法是:<br>var d : TDate; t:TTime; dt : TDateTime;<br>begin<br> dt := now;<br> d := TDate(dt);<br> t := TTime(dt);