Normal Topic Calendar date field entry (Read 1891 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Calendar date field entry
Dec 22nd, 2009 at 8:27pm
Print Post Print Post  
I was able to change the way that a field would show a date when entered via the calendar to “12/22/2009”, that’ the way my client wants it to look.  I did this using the display format for selected elements.   While in add or update mode this works great, however while in search mode it shows the date as 2009/12/22, the Sesame internal date format.  I’ve been into Application Property Manager to set the default display format to 12/22/2009 but that doesn’t change it while in search mode.

Is there a way to change it for search mode?

Thanks
  
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Calendar date field entry
Reply #1 - Dec 22nd, 2009 at 11:54pm
Print Post Print Post  
Here's a little proof of concept code. The key section that you need to add to your code is highlighted in red.

var MyDate as String

MyDate = @Calendar(@Date, "MyTitle")
MyDate = @Right(MyDate, 5) + "/" + @Left(MyDate, 4)

WriteLn(MyDate)
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Calendar date field entry
Reply #2 - Dec 23rd, 2009 at 12:30am
Print Post Print Post  
Thanks for the response Carl.

I applied your code, the writeln result shows the date in the correct format but when I direct the result to the date field it stays in the old format, and again only in search mode.  If I direct it to a non-date field it works just fine.  Is it not a good practice to designate a field as a date field?  I'm doing it with this application because searching by date is critical.

Thanks

Brandon
  
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Calendar date field entry
Reply #3 - Dec 23rd, 2009 at 1:39am
Print Post Print Post  
I see what you mean.

You must be assigning the value to the date LE with something like this:
Code
Select All
LE1 = MyDate 



You can get it to do what you want by using FormFieldValue instead:
Code
Select All
FormFieldValue(@Layout + ":(Search)", "LE1", 0, MyDate) 


  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Calendar date field entry
Reply #4 - Dec 23rd, 2009 at 1:56am
Print Post Print Post  
tcgeo wrote on Dec 23rd, 2009 at 12:30am:
Is it not a good practice to designate a field as a date field?  I'm doing it with this application because searching by date is critical.

No. You do want it to be a real date field, mainly for the reason you describe; but also because Sesame can alert the user if they tried to enter an invalid date. A real date field keeps users from entering garbage like "Dec '09" or "Dec 22nd", etc. Date entries like that would be of little use to you from a programming viewpoint.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Calendar date field entry
Reply #5 - Dec 23rd, 2009 at 2:01am
Print Post Print Post  
Outstanding Carl!

Thank you very much.

How in the world did you come up with that?
  
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Calendar date field entry
Reply #6 - Dec 23rd, 2009 at 2:26am
Print Post Print Post  
Here is an untested idea ....

Create a text field that is only visible in Search Mode.  Make that field visible, and the normal DATE field invisible.  Let the user input the date into the visible text field.  Then use Carl's technique to reformat the date and apply the result to the Search spec, DATE=TempTextElement.  Make the TempText element invisible again when the form opens in the data entry/view modes.

You could actually put the TempText element in the same position as the normal date field with identical label, the user will not know the difference.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Calendar date field entry
Reply #7 - Dec 23rd, 2009 at 11:15am
Print Post Print Post  
Thanks for the idea Bob, I'll check that out.  Carl's code does work beautifully.  I just inserted my field name for LE1 and problem solved.

Brandon
  
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Calendar date field entry
Reply #8 - Jun 8th, 2016 at 4:47pm
Print Post Print Post  
Hello, thanks for all the great info on this idea.

I'm trying to do something similar if not exactly the same myself but have just started coding. I've researched each of the commands thoroughly and have implemented a few things experimenting.

But is it possible if I could see what you have exactly/in totality for your calendar button code?

I'm not really sure where I'm supposed to put @FormFieldValue, etc.
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: Calendar date field entry
Reply #9 - Jun 8th, 2016 at 5:22pm
Print Post Print Post  
Well, I tried this and it seems to work.

Code
Select All
Var vAppt_Date as String

	//Bring up calendar to select appointment date
	vAppt_Date = @Calendar(@Date, "Esc to cancel")

	If Not @Error Then
	{
		//Only set value of Appt_Date element if user selected a date
   		Appt_Date = vAppt_Date
	}

	//Changes format of appointment date to dd/mm/yy
	vAppt_Date = @Right(vAppt_Date, 5) + "/" + @Mid(vAppt_Date, 3, 2)

	//Forces date format in Search Mode
	FormFieldValue(@Layout + ":(Search)", "Appt_Date", 0, vAppt_Date) 

  
Back to top
 
IP Logged