Sam Van Deest
posted this on March 26, 2009 15:24
Next to the input(to the right, place the fieldname in the script where it says 'fieldname'
<span style="cursor:pointer;" onclick="OpenBoardDateTimePicker(event,'fieldname','true');">
<img src="../lib/cal.gif" width="16" height="16" border="0" alt="Pick a date"></img></span>
Example
<input type="text" name="crestdate" size="30" required="false"></input>
<span style="cursor:pointer;" onclick="OpenBoardDateTimePicker(event,'crestdate','true');">
<img src="../lib/cal.gif" width="16" height="16" border="0" alt="Pick a date"></img></span>
UPDATE:
If you are wanting to record the date only, without the time, then you just need to change the 'true' at the end of the OpenBoardDateTimePicker function to 'false'.
Example:
<input type="text" name="crestdate" size="30" required="false"></input>
<span style="cursor:pointer;" onclick="OpenBoardDateTimePicker(event,'crestdate','false');">
<img src="../lib/cal.gif" width="16" height="16" border="0" alt="Pick a date"></img></span>
NOTE: if you have previous data you may want to add this fieltype="datetime" attribute to the input <input type="text" name="crestdate" size="30" required="false" fieldtype="datetime"></input>
Comments
Sam, I'd like to add this calendar shortcut but without the time. Is there an "OpenBoardDatePicker(event)?"
Doreen,
If you're after just a date, the best way to get that is to create an input that automatically populates with just the current date or the _currentdate.
An example is below:
<input type="text" name="just_date" size="40" value="_currentdate" required="false"></input>
The value="_currentdate" attribute will populate the input with the current date automatically. You can then bring up the calendar to pick just the date.
We had an application where we only wanted the calendar picker but did not want to auto-populate the field with the _currentdate. Andrew Price provided me with the code above but changing true to false will yeild the desired result:
<input type="text" name="crestdate" size="30" required="false"></input>
<span style="cursor:pointer;" onclick="OpenBoardDateTimePicker(event,'crestdate','false');">
<img src="../lib/cal.gif" width="16" height="16" border="0" alt="Pick a date"></img></span>
I've tried this code and all I'm able to get is a date picker. Does anyone know how to get the time picker to work? I want my users to have to pick both the date and the time values for the sake of consistency.
Hi All,
I have got the calender to show, and input the selected date on the input field but i then have 2 subsequent problems.
1 On my display boards it shows the date, but also the time as a blank. EG 04/04/1981 00:00:00
2 Upon editing the record, the input field now also shows the blank time. EG 04/04/1981 00:00:00
Is there a way to stop the erroneous time from being displayed ? i have tried using the format attribute
(example(excluding calender span and img source from above):
<input type="text" fieldtype="datetime" format="0:d" name="FieldName" class="inputtextField" ></input> )
in the hope that it would create a 'date' formatted sql field rather than a 'datetime'... but no luck...
This field cannot use _currentdate, and i noticed that this didn't help either.
What is the best way to ensure that the blank zeros are not shown on either a display board or an input board. All help apprechaited.
Cheers,
Charlie.
National Critical Care & Trauma Response Centre
Darwin, Australia.
Darwin,
You will have to cast your field as a datetime field and covert it to the mm/dd/yyyy format like so:
<expression name="fieldname1">convert (varchar(10), cast(fieldname as datetime),101)</expression>
hide the <eocfield name="fieldname" /> in a span like so:
<span style="display:none"><eocfield name="fieldname" /></span>
Frances,
Please provide this same date conversion code using a relatedexpression for a date being pulled from another table. I've tried this using your code, but I keep receiving an "Invalid column name 'fk_table_###" error. What am I doing wrong?
<relatedexpression name="DueDate" table="Health Task">convert(varchar(10), cast(Due as datetime),101)</relatedexpression>
Thanks,
Becky
Becky and anyone else wanting to record the date without the time:
Please see the update above.