Avatar of Dusty
Dusty
Flag for United States of America asked on

DateTime function question

If I have a dateTime field in MySQL database and is formatted like : 2014-03-30 02:00:00

but i only want to use the date portion, how would you extract that? code example appreciated!

Thanks!
ColdFusion Language

Avatar of undefined
Last Comment
Tom

8/22/2022 - Mon
SOLUTION
Ganapathi

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Tom

All about it here:
https://wikidocs.adDateTimeFormatobe.com/wiki/display/coldfusionen/
Read the comments some correction to the code.

And don't forget to replace the tag "todayDateTime" with the field name from sql
Dusty

ASKER
Maybe I did not ask the question correctly.
I already have many records in my database with dateTime  field and they are formatted like:
2014-03-30 02:00:00
2013-05-03 06:00:00

I want to extract just the date portion and use that as a coldfusion variable.
ASKER CERTIFIED SOLUTION
gdemaria

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Ganapathi

While selecting the data from database, use the below function for the date column

DATE(date_column_name)

You will get yyyy-mm-dd
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Dusty

ASKER
Thank you! I have split the points.
Tom

#DateTimeFormat(SQLLabelName, "yyyy.MM.dd")#
This will mask out the date