When calling the date function, or referencing database information from a 'date' field, is it possible to specify what format the date will be returned as? Windows has at least seven formats that I know of, two of which (mm/dd/yy and yy/mm/dd) are impossible to tell apart with my current code. I'm trying to isolate just the year value from the date, and it's causing problems for my programs when they get run on systems that don't have the same date format as my own. The dates get reformatted to the host system's format, which might not have the year in the same position(s). Anyone have any advice on this issue?

Thanks in advance,

10 Years
Discussion Span
Last Post by Lord Soth


You can use the FormatDateTime function to convert a TDateTime structure to a string with a formatting of your choice. While accessing database record fields use AsDateTime then FormatDateTime not AsString.

Example from Delphi 7 Help :
S := FormatDateTime('"The meeting is on " dddd, mmmm d, yyyy, " at " hh:mm AM/PM', Now + 0.125);

Loren Soth

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.