Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Date Formatting 1

Status
Not open for further replies.

CHeighlund

Programmer
Jun 11, 2007
163
US
I know it's possible to turn a date from the default system format to an alternate format with the FormatDateTime() command and put it into a string. Is there some way to reverse this particular effect? I'm trying to do date comparisons between two user-entered dates, but the user enters each date with a pair of ComboBoxes (for month and day) and a TextBox for the year. I can't guarantee that all users will have the same default date formatting on their systems, and attempts at kludging the date into a string and attempting StrToDate() on it fail because my resulting string's format doesn't match the box's date format.

Anyone have any suggestions on how to solve this? Or should I be looking at other ways to get the information I need instead?
 
try EncodeDateTime Function.
... From Delphi 7 Help:
EncodeDateTime returns a TDateTime that represents a specified year, month, day, hour, minute, second, and millisecond.

Delphi syntax:

function EncodeDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word):TDateTime;

hope this can help
Giovanni
 
Thank you. EncodeDateTime requires a bit too much information, but that lead me to the EncodeDate() function, which looks (and so far acts) like precisely what I needed. Again, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top