Delphi的DateToStr StrToDate格式灵活用法
2008-04-09 10:19

procedure TForm1.Button1Click(Sender: TObject);
var
   ADate: String;
   ADate2: TDate;
   AFormat, AFormat2: TFormatSettings;
begin
   AFormat.ShortDateFormat := 'ee/mm/dd';
   AFormat.DateSeparator := '/';
   ADate := '94/05/15';
   ADate2 := StrToDate( ADate, AFormat );
   AFormat2.ShortDateFormat := 'yyyy/mm/dd';
   AFormat2.DateSeparator := '/';
   ShowMessage( DateToStr( StrToDate( ADate, AFormat ), AFormat2 ) );
end;

其中,最重要的就是TFormatSettings这个类.

可以设置AFormat.shortDateFormat:='yyyymmdd'

DateToStr(ADate,Aformat)得到字符串就是类似20080409的字符了.

如果是'yymmdd'则为080409的字符

Delphi的DateToStr StrToDate格式灵活用法的更多相关文章

  1. Delphi中stringlist分割字符串的用法

    Delphi中stringlist分割字符串的用法 TStrings是一个抽象类,在实际开发中,是除了基本类型外,应用得最多的. 常规的用法大家都知道,现在来讨论它的一些高级的用法. 1.CommaT ...

  2. 教程-Delphi中Spcomm使用属性及用法详解

    Delphi中Spcomm使用属性及用法详解 Delphi是一种具有 功能强大.简便易用和代码执行速度快等优点的可视化快速应用开发工具,它在构架企业信息系统方面发挥着越来越重要的作用,许多程序员愿意选 ...

  3. Delphi 类的类 class of 用法

    http://blog.csdn.net/blue_morning/article/details/8815609 Delphi 类的类 class of 用法   这个概念本来在一个关于Delphi ...

  4. 9.11 Django关于母版语言的灵活用法

    2018-9-11 12:45:38 还是这个连接 : http://www.cnblogs.com/liwenzhou/p/7931828.html 注意: 这节讲的是  母版语言的灵活用法!  可 ...

  5. Delphi中TxmlDocument控件的用法 转

    Delphi中对XML文件的解析做的很好,比直接使用MS的MSXML2_TLB中的接口要方便很多,现称述于下面. 在讲之前先给出一个XML实例,在讲某些部分是要结合实例比较容易理解. 1<?xm ...

  6. delphi 最全日期格式_DateUtils时间单元说明

    DateUtils时间单元说明 CompareDate 函数 比较两个日期时间值日期部分的大小 CompareDateTime 函数 比较两个日期时间值的大小 CompareTime 函数 比较两个日 ...

  7. setprecision(int n)等格式函数用法 分类: POJ 2015-06-11 10:56 17人阅读 评论(0) 收藏

    **这些用法前最好用 #include <iostream>    //不要用iostream.h ,会出现好多问题 #include <iomanip> // io 流控制头 ...

  8. 设置Delphi默认按utf8格式保存单元文件

    Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Editor] " ...

  9. (转载)C#关于DateTime得到的当前时间的格式和用法

    今天看到工程里有关DateTime的有关知识,之前了解一些用法,比如怎么获取年月日,当前系统时间等等,但是,感觉还是有好多不知道,于是上网搜罗了一下,找到很多有关知识,现在与大家分享下:   Date ...

随机推荐

  1. table_横向合并_纵向合并

    colspan是横向合并; rowspan是纵向合并; <caption></caption>表格标题(自动居中)

  2. php 表单提交

    <?php header("Content-Type:text/html; charset=utf8"); class config{ public static funct ...

  3. 9G10内核时钟tick实现

    9G10中PIT(Periodic Interval Timer)提供OS调度中断,它提供了最高精度和最有效的管理(即使系统长时间响应).一. 硬件PIT目标是提供OS的周期中断.PIT提供一个可编程 ...

  4. iOS 归档

    #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...

  5. Using Amazon API Gateway with microservices deployed on Amazon ECS

    One convenient way to run microservices is to deploy them as Docker containers. Docker containers ar ...

  6. ios9 升级后 企业版app plist无法安装

    昨天apple推送了ios9, 公司的一些app是企业版的,平常通过 item-service 结果更改如下 plist可以了 itms-services://?action=download-man ...

  7. Apache, Nginx获得nginx代理后的真实用户Ip

    Nginx 的反向代理设置  proxy_set_header X-Real-IP $remote_addr; apache可以设置日志格式将 %h替换为 %{X-Real-Ip}i 如: LogFo ...

  8. PDB重命名

    PDB重命名 将PDB clonedb重命名为rdb SQL> select name,open_mode from v$pdbs; NAME OPEN_MODE --------------- ...

  9. PAT 解题报告 1003. Emergency (25)

    1003. Emergency (25) As an emergency rescue team leader of a city, you are given a special map of yo ...

  10. CareerCup: 17.14 minimize unrecognized characters

    Oh, no! You have just completed a lengthy document when you have an unfortu- nate Find/Replace misha ...