954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Date formatting?

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,
-EnderX

EnderX
Posting Shark
999 posts since Aug 2006
Reputation Points: 483
Solved Threads: 1
 

Hi,

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

Lord Soth
Posting Whiz in Training
233 posts since Mar 2006
Reputation Points: 28
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You