Coldfusion / MySQL question

Cf 10 / MySQL 5.6

In my database table is a field "DaysOnMarket"  I need to populate that field by subtracting the "ListDate" of the property (which I get in a RETS feed and is in the table) from today's date. Which I can calculate below:

<cfset todayDate = DateFormat(Now(),"yyyy-mm-dd")>

<cfset DaysOnMarket = #TodayDate#-#ListDate#>



What I want is to be able to update the "DaysOnMarket" field for all the records in my table.

Whats the best way to accomplish this?  I'm using LOAD DATA INFILE to get .txt file data into the table.

Can it be done at the same time the records are loaded into the database using LOAD DATA INFILE using SET? or should it be done directly after the records are loaded?

Code sample appreciated.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Don't have time to test it right now, but two possibilities come to mind:

1) Add an INERT TRIGGER to the table. The trigger would update the "DaysOnMarket" value whenever a record is inserted.  The advantage is it's a one time operation, and it would apply to any INSERT into that table - individual inserts or via LOAD DATA.
2) LOAD DATA offers a `SET` clause which allows you to modify inserted values at the time of insert.  Looking at the docs you'd probably use something along these lines:

  (ListDate, ... other columns )

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bang-O-MaticAuthor Commented:
Exactly what I was looking for!
Works perfect!

Thanks for the help _agx_!
Bang-O-MaticAuthor Commented:
Perfect solution! thanks _agx_!
Cool. Glad I could help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.