troubleshooting Question

Need format in Query ??

Avatar of Overthere
Overthere asked on
Microsoft SQL Server
3 Comments3 Solutions102 ViewsLast Modified:
I have a problem which confuses me.

I added a column, ChangeDate, datatype of datetime and set the default value/Binding to getdate().
I populated the ChangeDate column, using a query by extracting  from another column, RecUpdate, datatype nvarchar(50).
RecUpdate looks like this: UPDATED-4/6/2011 10:11:59 AM. This a string created with coding.
Notice the format of the date is M/D/YYYY
The query executed fine, but it formatted the dates this way: 2011-04-06 10:11:59.000. It formatted it as YYYY-MM-DD.
Why is this? Do I need to add a format to my query? The query is listed below:
Update BuildingMaster set ChangeDate = (cast(SUBSTRING(RecUpdate 9, 30) AS datetime))
ASKER CERTIFIED SOLUTION
TONY TAYLOR

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros