Delphi中如何用格式化对时间和日期进行限定?
我原来是用CB的,
CB里面有一个Date->FormatString("")
或Time->FormatString("");对日期或时间进行格式化,
请问Delphi中如何进行操作????

解决方案 »

  1.   

    FormatDateTime('yyyy-mm-dd')
    FormatDateTime('yyyy')
    FormatDateTime('mm')
      

  2.   

    FormatDateTime('yyyy-mm-dd HH:MM:SS' ,now)
    FormatDateTime('yyyy-mm-dd' ,now)
    FormatDateTime('yyyy',now)
    FormatDateTime('mm',now)
      

  3.   

    ADODataSet_Time.Value
        := StrToDateTime(FormatDateTime('yyyy-m-d', DTP_Time.Date));
      

  4.   

    formatedatetime(formatstring,datetime)
      

  5.   

    上面已提到:
    FormatDateTime('yyyy-mm-dd',Date)
    FormatDateTime('yyyy',Date)
    FormatDateTime('mm',date)
    但还可以对他进行转换
    如:
    我可以将他转化为整型或字符串
    DateToStr(FormatDateTime('mm',date))
    DateToInt(FormatDateTime('mm',date))
    其他类似。