Amend date field in SQL Statement

Hi Experts

I have the following line of SQL Statement

ISDATE(created_dateonly) as created_date_only,
which in column Created_dateonly is the date in format 2012-12-06 and in column Created_Date_only shows 1 and 0.....

how can i change the SQL so in column Created_date_only the date is in the format 25/09/2013...
route217JuniorAsked:
Who is Participating?
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.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
you may want to use this article to handle date/time vs string correctly:
http://www.experts-exchange.com/Database/Miscellaneous/A_1499-DATE-and-TIME-don%27t-be-scared-and-do-it-right-the-first-time.html

you may try this expression:
CASE WHEN ISDATE(created_dateonly) = 0 then created_dateonly
   ELSE CONVERT(VARCHAR(10), CASE WHEN ISDATE(created_dateonly) = 1 then created_dateonly ELSE NULL END, 103) end  

Open in new window

0
route217JuniorAuthor Commented:
hi angeliii

the expression works but the new column created to the right the date is still in the format 2012-12-06.......not as 06/12/2012...
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sorry ... we need "double conversion":
CASE WHEN ISDATE(created_dateonly) = 0 then created_dateonly
   ELSE CONVERT(VARCHAR(10), CONVERT(datetime, CASE WHEN ISDATE(created_dateonly) = 1 then created_dateonly ELSE NULL END , 120 ), 103) end   

Open in new window

0

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
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

route217JuniorAuthor Commented:
hi angeliii

you're second expression works...but a hand full of date s are still appearing in the  format 2012-06-12......hmmmmmm
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you show examples?
maybe isdate() is returning 0 ...
0
PortletPaulfreelancerCommented:
FYI:

ISdate(created_dateonly)

note the IS in ISDATE()

often a function that has the word IS and then another word
will return 1 (meaning true) or 0 (meaning false)

It's like verbally asking "Is this value a date?"
(a 'closed question' requiring a Yes or No answer)

exception:
ISnull( test-value, substitute-value )

regrettably there is at least this one exception
0
route217JuniorAuthor Commented:
angeliii

correct the is date is returning a 0....
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
then let's check on which values it's doing that.
0
route217JuniorAuthor Commented:
hang fire...
0
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
Microsoft SQL Server

From novice to tech pro — start learning today.