×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Date checking function

Date checking function

Date checking function

(OP)
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

RE: Date checking function

You can use the functions copy, pos and val:

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:
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
http://student.vub.ac.be/~bvingerh/
Don't worry what people think about you. They're too busy wondering what you think about them.

RE: Date checking function

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close