新手+菜鳥,請教關於取當天日期的問題

來源:互聯網
上載者:User
新手+菜鳥,請教關於取當天日期的問題 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiBase/html/delphi_20061220153528104.html
我想讓DateTimePicker.Date的值等於當天的日期  
  我的寫法如下:  
              DateTimePicker.Date:=FormatDateTime('yyyy-mm-dd',Now);  
  結果不對,請教高手!

這個問題不需要問高手,小弟來回答:  
   
    DateTimePicker.Date:=FormatDateTime('yyyy-mm-dd',Now);  
   
  中等號左邊是日期型資料,右邊是字元型資料.報錯是當然的啦.改成:  
   
  DateTimePicker.Date:=Now;   就可以啦.  
   
  分都給我吧,謝謝老兄啦

哈哈   頂樓上的   ~~

呵呵,謝謝春風不語,我自己也解決了,跟你的不太一樣,  
  DateTimePicker.DateTime:=FormatDateTime('yyyy-mm-dd',Now);放出來給大家看一下,  
  不過分我照給就是了,呵呵

謝謝了

var  
  strTime:   string;  
   
  strTime   :=   FormatDatetime('yyyy-mm-dd   hh:nn:ss',   now);  
   
  'yyyy-mm-dd   hh:nn:ss'對應   年-月-日   小時:分:秒

小便宜  
  你用什麼方法啊,貼上來看看

procedure   TForm1.Button1Click(Sender:   TObject);  
  begin  
        DateTimePicker1.DateTime:=strtodatetime(FormatDateTime('yyyy-mm-dd   hh:nn:ss',now));  
        showmessage(datetimetostr(DateTimePicker1.DateTime));  
  end;

樓上讓人無語

暈死!

DateTimePicker.Date   :=Date   //只取日期

DateTimePicker.Date   :=Date;   //只取日期  
  DateTimePicker.DateTime   :=now;   //時間  
 

呵呵,真可笑

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.