Recent

Author Topic: Displaying a date as MMM YYYY  (Read 2672 times)

talorigomat

  • Jr. Member
  • **
  • Posts: 96
Displaying a date as MMM YYYY
« on: June 30, 2016, 03:07:59 pm »
How do you use the custom number format.  I want to write a date so it displays like: Jan 2010.
Lazarus 1.8.0Rc4, Windows 10

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Displaying a date as MMM YYYY
« Reply #1 on: June 30, 2016, 03:38:06 pm »
Use FormatDateTime function with FormatStr parameter.
See the complete list how to use FormatStr parameter here: FormatChars

For example:
Code: Pascal  [Select][+][-]
  1. var
  2.   S: String;
  3.   D: TDate;
  4. ...
  5.   S := FormatDateTime('mmm yyyy', D);

 

TinyPortal © 2005-2018