Hello everyone. I have a datetime field in SQL and it stores date & time and I'd like to display "just" the date on the .cfm. How do I convert the data retreived in the query? Thanks.
Or you could return the date, already formatted, from SQL Server:
SELECT CONVERT(varchar(10),dateField,101) AS dateField
This will return every column named dateField that is a datetime or smalldatetime in the format "mm/dd/yyyy". Look up the CONVERT function in SQL Server Books Online to see alternate formats.
Ecobb is right, and that's the solution I would have posted, but I'd take Tek's suggestion into consideration... If your output is a heavily visited page or outputs many dates..
It is better to share the load..
A lot of developers, for instance, run insert queries like this..
INSERT INTO TABLE(cID,Date)
VALUES('#form.cID#','#Now()#')
And while that's nice, with most databases, you can set the default of the field in the db to the current time (at insert) so that your query only needs to be.
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.