如何获取当前时间(单位:秒)与标准时间(1900/01/01/00:00)的差呢?主要是想用当前时间减去标准时间能够得到一个以秒为单位的Long型变量。有人知道用什么函数吗?

解决方案 »

  1.   

    select datediff(day, 0, getdate())
      

  2.   

    DATEDIFF ( datepart , startdate , enddate ) 其中datepart格式如下:
    year  
    quarter 
    Month  
    dayofyear  
    Day 
    Week 
    Hour 
    minute 
    second 
    millisecond 
      

  3.   

    uses
      DateUtils;procedure TForm1.btn1Click(Sender: TObject);
    begin
      ShowMessage(FloatToStr(DaySpan(Now, StrToDate('1900-01-01'))));
    end;
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      s:double;
    begin
      s:=now - strtoDateTime('1900/01/01 00:00');
      showmessage(floattostr(s*3600*24));
    end;一小時=3600秒
      

  5.   

    function DaysBetween(const ANow, AThen: TDateTime): Integer;
    function DaySpan(const ANow, AThen: TDateTime): Double;
    uses
      DateUtils;procedure TForm1.btn1Click(Sender: TObject);
    begin
      ShowMessage(IntToStr(DaysBetween(Now, StrToDate('1900-01-01'))));
    end;
      

  6.   

    如果用秒
    select datediff(second, 0, getdate())
    则会溢出,数值太大了!
      

  7.   

    uses 
      DateUtils;procedure TForm1.Button1Click(Sender: TObject);
    begin
      ShowMessage(FloatToStr(SecondSpan(Now, StrToDateTime('1900/01/01 00:00'))));
    end;