No one seemed to help me out with my other question :sad: so was wondering if you can help me with this one. I want to validate a date so that the user is only allowed to enter a correct date. I have no idea how I could do it and would appreciate if someone showed me some coding of how I can do it. I want the date to be in this format:

write(' Date Out (dd/mm/yyyy format)....');
readln(rr.date_out);
writeln;
write(' Date In (dd/mm/yyyy format)....');
readln(rr.date_in);

thanks :eek:

I'm not a pascal prpgrammer so I can't write the program for you, but it will be the same in any language.

First create three string objects called month, day and year then use substring (or something similar) that will extract the appropriate digits from the original string into each of the three objects. Next convert each of the three sub strings into integers. Finally check that the month is between 1 and 12, the day is between 1 and last day of the month.

thanks for the help but I kind of figured that out already! The probelm im finding is in coding it. thanks just the same

thanks for the help but I kind of figured that out already! The probelm im finding is in coding it. thanks just the same

you must post your code -- no one can help you if you do not.

what do I NEED TO POST? i THINK THERES NOTHING I CAN PASTE SINCE I CANT GET TO IT THE ONOLY THINK I MANAGED TO WRITE IS THE BIT I PASTED IN THE FIRST MESSAGE

>>what do I NEED TO POST?
well, what have you tried? you already said you figured out what you need to do -- thats a good start. Now try putting that down on paper, schetch out on paper what you need to accomplish. Not code at this point, but just ideas. Don't get overwhelmed with the assignment -- take it one small step at a time.

ok i managed to arrive here...I modified everything and made the date automatically. Now when the date is stored, it is only stroed in numbers example instead of Monday, 11/7/2007 it stroes as 11172007 . How can I make it store the date as it is dispayed? here is the code i did :

GetDate(year,month,day,dayofweek);
writeln(' Date Out.....', days[dayofweek],', ',month:0, '/', day:0, '/', year:0);
rr.date_out := WORDTOSTR(dayofweek)+WORDTOSTR(month)+WORDTOSTR(day)+WORDTOSTR(year);

by the way, WORTOSTR is a procedure I made to convert from word to string.

Does TDate not provide the functionality you require?

I think he means if the user enters a date and if it's in the wrong format, then the program tells the user that.

Correct me if I'm wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.