關於日期 |
答題得分者是:salo0610
|
zx4654
一般會員 發表:18 回覆:26 積分:8 註冊:2005-04-05 發送簡訊給我 |
|
salo0610
高階會員 發表:42 回覆:120 積分:107 註冊:2003-02-18 發送簡訊給我 |
我測 ok 啊, 一號時,Now()-1 也會 變成 前一個月的最後一天啊
TDate a = Now(); TDate b = Now()-1; unsigned short yy; unsigned short mm; unsigned short dd; a.DecodeDate(&yy,&mm,&dd); ShowMessage( String(yy) String(mm) String(dd) ); b.DecodeDate(&yy,&mm,&dd); ShowMessage( String(yy) String(mm) String(dd) ); |
salo0610
高階會員 發表:42 回覆:120 積分:107 註冊:2003-02-18 發送簡訊給我 |
TDateTime is the C analog for the Object Pascal TDateTime data type. Header systdate.h Description TDateTime implements the Object Pascal TDateTime data type and the date/time runtime library routines that use the TDateTime data type. The TDateTime class inherits a val data member declared as a double that holds the date-time value. The integral part of a TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a TDateTime value is the time of day. Following are some examples of TDateTime values and their corresponding dates and times: 0 12/30/1899 12:00 am 2.75 1/1/1900 6:00 pm -1.25 12/29/1899 6:00 am 35065 1/1/1996 12:00 am To find the fractional number of days between two dates, simply subtract the two values, unless one of the TDateTime values is negative. Similarly, to increment a date and time value by a certain fractional number of days, add the fractional number to the date and time value if the TDateTime value is positive. When working with negative TDateTime values, computations must handle time portion separately. The fractional part reflects the fraction of a 24-hour day without regard to the sign of the TDateTime value. For example, 6:00 am on 12/29/1899 is ?.25, not ? 0.25, which would be ?.75. There are no TDateTime values between ? and 0. Note: Use only the operators declared by TDateTime. The compiler ignores any operators you overload yourself. Warning: It is not possible to use TDateTime as a base class for inheriting. To add functionality to TDateTime, you must write a wrapper class. Note: If you #include ostream& operator << (ostream& os, const TDateTime& arg); istream& operator >> (istream& is, TDateTime& arg); |
zx4654
一般會員 發表:18 回覆:26 積分:8 註冊:2005-04-05 發送簡訊給我 |
===================引 用 salo0610 文 章=================== 我測 ok 啊, 一號時,Now()-1 也會 變成 前一個月的最後一天啊 TDate a = Now(); TDate b = Now()-1; unsigned short yy; unsigned short mm; unsigned short dd; a.DecodeDate(&yy,&mm,&dd); ShowMessage( String(yy) String(mm) String(dd) ); b.DecodeDate(&yy,&mm,&dd); ShowMessage( String(yy) String(mm) String(dd) ); 謝謝你,我剛試了的確可以。不過我用的是Now().operator --().FormatString("yyyymmdd")搞定了,感謝你的熱心。 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |