Skip to main content
Inspiring
October 24, 2006
Answered

Selecting Certain Parts of a Value

  • October 24, 2006
  • 3 replies
  • 353 views
I have attached the code I am using to test this out and make sure it works before implementing it. What I have is a database field which stores the date and time that they select. It keeps it in the form of yyyy-mm-dd hh:mm:ss. I want to pull all of those out to cfset variables so it would go something like...
<cfset year = "the yyyy value">
<cfset month = "the mm value">
and so on...

However, with the attached code, I am getting everything past the '-'. So if in the database it was 2006-10-8 10:40:23, it is showing 8 10:40:23. I want it to be just the 8.

My other problem is how to get the reast of the values out, and set all those different parts of the time to the different variables with the fucntions I do not know how to use:(. Any help would be great!

Thanks!!
This topic has been closed for replies.
Correct answer vksrinu
Hi

try this code.

3 replies

Inspiring
October 24, 2006
You have a datetime field. If your db has date functions they will work. If not, cold fusion date functions will work and they are a lot simpler than string functions.

To start, put google "coldfusion date functions".
Inspiring
October 24, 2006
You also may want to lookup the function DATAPART() as well. You can extract just parts of the date that you want, taking the value is a valid date/time object.

vksrinu
vksrinuCorrect answer
Inspiring
October 24, 2006
Hi

try this code.