Avatar of Overthere
Overthere
 asked on

Need format in Query ??

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))

Open in new window

Microsoft SQL Server

Avatar of undefined
Last Comment
PortletPaul

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
TONY TAYLOR

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Scott Pletcher

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
PortletPaul

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23