• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Selecting Certain Parts of a Value

Explorer ,
Oct 23, 2006 Oct 23, 2006

Copy link to clipboard

Copied

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!!
TOPICS
Advanced techniques

Views

260

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Oct 23, 2006 Oct 23, 2006
Hi

try this code.

Votes

Translate

Translate
Participant ,
Oct 23, 2006 Oct 23, 2006

Copy link to clipboard

Copied

Hi

try this code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 24, 2006 Oct 24, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 24, 2006 Oct 24, 2006

Copy link to clipboard

Copied

LATEST
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".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation