Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ignoring the time part of the date 1

Status
Not open for further replies.

leadman

Programmer
Joined
Jun 11, 2001
Messages
177
Location
US
when i query the database for a date i get the full date and time back (Date: 2001-12-06 15:55:51) -

I want to sort by date but not by the time - how could i go about this?
 
use CreateDate(year, month, day) ==>

<cfset odbcdate = (Date: 2001-12-06 15:55:51)>
<cfset date = ListGetAt(odbcdate, 2, &quot; &quot;)>

<cfset newDate = CreateDate(ListGetAt(date, 1, &quot;-&quot;), ListGetAt(date, 2, &quot;-&quot;), ListGetAt(date, 3, &quot;-&quot;))>

<cfoutput>#newDate#</cfoutput>

Sylvano
dsylvano@hotmail.com
 
What type of Database are you using? - tleish
 
If the field is already a date field, I would use the dateformat function. Something like this:

<cfquery name=&quot;get_date&quot; source=&quot;database&quot;>
SELECT *
FROM table
ORDER by DATE_FIELD
</cfquery>
(the time doesn't matter at this point because everything will be sorted by date first anyway)

<cfoutput query=&quot;get_date&quot;>
date: #dateformat(date_field,&quot;mm/dd/yy&quot;)#
</cfoutput>

The code in the other post looks like the manual way of doing what the dateformat() function does.
If you need to post to your date field, you'll need to do the createODBCdate function. Chandler
I ran over my dogma with karma!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top