Date Input Validation and Translation in Lotus Notes


How would you approach this problem?  I need to translate a date entry in a form field into the standard MM\\DD\YY or MM\DD\YYYY format so  the user dosen't need to enter the slashes.  At the same time, I want to validate the entry so that alpha characters would be rejected.  Will the @Date function work here or do I need to write a script.  

Please advise

Thank you - Mike
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Well making the field of a Date type would force a valid date to be entered into it.  I am not sure that I understand fully the part about no slashes but if what I think you are saying is that instead of inputing 10/20/2010 you want them to be able to enter 10202010 and have the slashes put in for them there are a few problems.. 1112010 could be 1/11/2010 or 11/1/2010 so without some type of separator it does not really work.

WIthout knowing exactly what you want I would look at using the input validation portion of the field to put in something like

@If(@IsError(@TextToTime( Fieldname  )); @Failure("Please enter a date in this field" ); @Success)

Prior to that you could try the replace function to replace spaces with slashes if they are going to enter spaces instead of slashes so you would end up with

@ReplaceSubstring( Fieldname; " " : "." : "-"; "/" )

so the whole thing would look like
@If(@IsError(@TextToTime( @ReplaceSubstring( Fieldname; " " : "." : "-"; "/" )  )); @Failure("Please enter a date in this field" ); @Success)
BEWARE of "translating" dates!!!!

ALWAYS use a DATE field and apply the "formatting" to the field (normally you would use the users setting, which could also be as in my case: 2010-10-27)

that way you will never have issues "working" (exporting/calculating) with the date values.

If you start meddling around with "text" formatting of dates you will (almost guaranteed) encounter problems later as soon as you need to "work" with those values
I guess I don't fully understand either.  Are the users entering the date into a field on a notes form?  If so, why not change the Style of the field from Notes Style to Calendar/Time Control.  That way the user just selects the date from a calendar and you're done.  Formatting is taken care of.
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

I'm not so sure about the statement that you never want to use text for dates, Lotus in it's infinite wisdom treats a date without a time associated with it as that date at Midnight.  If you have people in multiple time zones this is a major pain in the rear end, because two people looking at the same field see different days.  Sometimes text is a lot better than a date field in this regard.  As far as then Using that data goes if you have a date field that you want to work with in Lotusscript you have to create an item and then get the dateTime value from that item to work with it so I don't know how it is easier to do a fieldGetText and using that text to create a New NotesDateTime than it is to set an item and then use the datetime value of the item.  As far as exporting it goes, I wish that Notes Date Time values always lined up perfectly to the data types of every database you wanted to export data to.
Ipinky is right if you have people in India and People in the US you may want to use a date (with a time) because in this instance the date and time in one zone occurs at a completely different date and time in the other zone so you don't really do a good job of controling aging without using both the date and time.  
For different zones in the US I would say either use a date AND a time or use text for different countries use a date AND a time..
You'll want to have two "field" objects on your form. One field for input, and a second field/computed text blob for display. Validate the text field manually, and then display it using a convert formula, something as simple as
textValue := name_Of_Text_Field;
  @Left(textValue;2) + "/" +
  @Middle(textValue;2;2) + "/" +

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BulldogMike: as I stated earlier: dates are dates and how they "display" depends on the settings of the field (ie how the designer wants dates to look like)

if the designer decides dates can look like the user wants them to look like he may do so...

and as we are talking not only about "displaying" but also entering dates in a proper format my suggestion is: go with the user settings, as the user is used to enter dates on his machine in this format!

HE will then see those dates in his format (eg. 2010-08-23)
YOU will see then the dates in your format (eg. 2010/08/23, or 23.8.2010 etc..)

it's really just a display thing and I don't quite understand why you would force the dates to look like you want them to look like.

If there is a "corporate" standard (eg. we use 2010-08-23) then apply this setting to the display of the field.

And as long as you have the "datepicker" for entering dates this ain't gonna be a problem for users anyway as then the format will always be correct
BulldogMikeAuthor Commented:
Thanks to everyone who responded to my question.  I learned something form all of you but I am not sure I aske the question properly to get the desired respones and will reward all of you with points if allowed
Thank You again
BulldogMikeAuthor Commented:
Thanks again to eryone for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.