aharown07 Posted February 17, 2006 Posted February 17, 2006 (edited) 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 February 17, 2006 by Guest
Søren Dyhr Posted February 17, 2006 Posted February 17, 2006 Hows about this: Replace ( Replace ( Filter ( Entry;"0123456789" ) ; 5 ; 0 ; "-" ) ; 3 ; 0 ; "-" ) Where the resulting field type is Date? --sd
aharown07 Posted February 21, 2006 Author Posted February 21, 2006 I'm quite new to Replace... but it doesn't seem to work. If I enter "1-1-06" or "01-01-06" it returns 11-20-06... not sure why. And "010106" it won't take at all.
Recommended Posts
This topic is 6914 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 accountSign in
Already have an account? Sign in here.
Sign In Now