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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date checking function

Status
Not open for further replies.

gsbeaton

Programmer
Apr 30, 2003
1
GB
Hello,

Can anyone suggest a range checking function for a date. I want to check that a date has been entered in the format 00/00/0000 but I'm having problems concatening the date parts and seperating the slashes in order that the input can be tested.

I'd appreciate any thoughts or ideas.

George
 
You can use the functions copy, pos and val:
Code:
FUNCTION copy(s : string; index : integer; count : integer) : string;
FUNCTION pos(substring : string; s : string) : byte;
PROCEDURE val(s : string; var value; var code : integer);
Copy returns a substring from the given string s with first character s[index] and count characters; if count specifies more characters than there are past index, the remainder of the string is returned.
Pos returns the position of the substring is the given string s; 0 if not present.
Val converts a string representing a number into a number, code indicates the first erroneous character in the string.

Example:
Code:
separator:=pos('-',postcode);
country:=copy(postcode,1,separator-1);
val(copy(postcode,separator+1,length(postcode)),city,code);
If postcode was 'B-2000' then
separator = 2
country = 'B'
city = 2000
code = 0


Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.
 
And remember that the UK and USA have opposite conventions about which way round the month and day are written....
03/10/2003 is ambiguous.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top