Ask a Question related to Coldfusion Database Access, Design and Development.
-
rhellewell #1
formatting a date in cfselect
Assuming a query "meetingdate" that grabs a unique value of the 'meetingdate'
field (a date/time field). In a form, that query is used to populate a cfselect
command.
The dropdown boxes now contain "yyyy-mm-dd hh:mm:ss" value (as in "2006-06-12
12:23").
How do I format the drop-down values into 'mm/dd/yy", as in "06/12/06" ? Using
the formatdate in the 'display' argument of the cfselect command returns an
error.
Or, should the query command contain some sort of formatdate function (and
what would that be)?
Thanks....Rick...
rhellewell Guest
-
Date Formatting
Use the Day function. response.write day("12/1/2003") Of course, is that date the first of December, or the twelth of January? I suggest you... -
Formatting and sorting date
I have an asp page which displays records from an access table. One of the fields in the table is a date field. The regional settings on the... -
formatting date
On 30/7/03 2:18 PM, in article bg7guu$b7j$1@forums.macromedia.com, "JemJam" <webforumsuser@macromedia.com> wrote: The systemDate object will... -
Date - formatting
I'm needing to assign the following variable with the following data from the date. Does anyone have any help they could offer please? date_day =... -
Date Formatting Issue
I have Access 2000. On a form, I want to show (in an unbound text box) how long an agreement has been effect, and format it in years and days. ... -
Ian Skinner #2
Re: formatting a date in cfselect
Use appropriate SQL functions to format the field in the query, would
depend on the DBMS system you are using (MSSql, MYSql, Access, Oracle, etc).
OR
Use <select> instead of <cfselect> where you can use a basic loop to
populate the <option> tags and format the date in the loop.
OR
Use a Query of Query or manually build a query out of the original query
modifying the format of the date string and use this new query in the
<cfselect> tag.
rhellewell wrote:> Assuming a query "meetingdate" that grabs a unique value of the 'meetingdate'
> field (a date/time field). In a form, that query is used to populate a cfselect
> command.
>
> The dropdown boxes now contain "yyyy-mm-dd hh:mm:ss" value (as in "2006-06-12
> 12:23").
>
> How do I format the drop-down values into 'mm/dd/yy", as in "06/12/06" ? Using
> the formatdate in the 'display' argument of the cfselect command returns an
> error.
>
> Or, should the query command contain some sort of formatdate function (and
> what would that be)?
>
> Thanks....Rick...
>Ian Skinner Guest
-
MikerRoo #3
Re: formatting a date in cfselect
It's always better to do this kind of thing in the query.
Here's the MS access syntax:
SELECT
Format(DATE_COLUMN, "mm/dd/yy") AS PurtyDate
FROM
YOUR_TABLE
Other DB's are similar.
MikerRoo Guest
-
rhellewell #4
Re: formatting a date in cfselect
This works (thanks!)
SELECT DISTINCT
Format(DATE_COLUMN, "mm/dd/yy") AS PurtyDate
FROM
YOUR_TABLE
but this doesn't
SELECT DISTINCT
Format(DATE_COLUMN, "mm/dd/yy") AS PurtyDate
FROM
YOUR_TABLE
ORDER BY DATE_COLUMN
and this doesn't
SELECT DISTINCT
Format(DATE_COLUMN, "mm/dd/yy") AS PurtyDate
FROM
YOUR_TABLE
ORDER BY Format(DATE_COLUMN, "mm/dd/yy")
Both throw the error:
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
Access Driver] ORDER BY clause (meetingdate) conflicts with DISTINCT.
(Intent is to have unique date_columns, sorted by date_columns, formatted as
'mm/dd/yy')
...Rick...
rhellewell Guest
-
MikerRoo #5
Re: formatting a date in cfselect
SELECT DISTINCT Format(DATE_COLUMN,"mm/dd/yy") AS PurtyDate
FROM YOUR_TABLE
ORDER BY Format(DATE_COLUMN,"mm/dd/yy")
does work.
You must have something else going on with your real query.
Attach the real query and attach the full error message (which includes
generated SQL).
MikerRoo Guest
-
rhellewell #6
Re: formatting a date in cfselect
This works (I may have typo'd the problem earlier)
SELECT
DISTINCT format(meetingdate,'m/dd/yy') as cmeetingdate
from documents
ORDER BY format(meetingdate,'m/dd/yy')
with this (note the use of the alias for the display and value parameters
<cfselect name="MeetingDate"
size="1"
message="Select the Meeting Date from the drop-down list"
query="MeetingDateList"
value="cmeetingdate"
display="cmeetingdate"
queryPosition="below"
width="10">
<option value="">*** any meeting date ***</option>
</cfselect>
rhellewell Guest



Reply With Quote

