Jump to content

very very versatile date field


This topic is 5689 days old. Please don't post here. Open a new topic instead.

Recommended Posts

OK, one for you calculation geniuses.

I have developed a solution for a client. They want to key in dates like this:

010106

and have them change into 01/01/06 (or 1/1/2006, etc. ...any real date)

Right now I am doing this with a text field I call something like DateKeyin. A calc does a conversion then a real date field grabs the result.

There must be a better way.

What's worse is that it punishes people who enter dates as dates. That is, I've got it smart enough to allow 01/01/06 but it won't take 1/1/06 or 1/1/2006.

Here's my calc for what it's worth:

If(IsEmpty(DateKeyIn);Right(0&Month(Get(CurrentDate));2)&"/"&Right(0&Day(Get(CurrentDate));2)&"/"&Right(Year(Get(CurrentDate));2)

;Let (D=DateKeyIn;

Case(

Filter(D;"/")="//";If (Length(D)=8;D;"?");

Filter(D;"/")="";If (Length(D)=6;Left(Left(D;4);2)&"/"&Right(Left(D;4);2)&"/"&Right(D;2);"?")

)

)

)

So is there a way to get this text field to also accept 1/1/06 or even 1/1/2006?

Better yet, I'd love to scrap the whole text field thing and get a real date field to process 010106 into 01/01/06 (or whatever way one wants to display it).

Can that be done?

One other thing... that first little bit in the calc is to get it to insert the current date by default. Then it processes what you key in as an auto enter replace.

I think the reason I went to a text field had something to do w/validation problems I ran into.

Edited by Guest
Link to comment
Share on other sites

This topic is 5689 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.