Solved

SQL - Update Statement Date Formatting

Posted on 2013-01-21
2
327 Views
Last Modified: 2013-01-21
Good Day Experts!

I need to update a field in one of my SQL tables via Qry Analyzer.  The field is Varchar and I need it to be 1/18/2013 4:41:00 PM.  

Since the field is Varchar do I just set the field to string '1/18/2013 4:41:00 PM' in my query?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
virtuadept earned 175 total points
ID: 38801366
UPDATE table SET column = '1/18/2013 4:41:00 PM' WHERE ??? (identify the row)

important: if you do not specify a WHERE clause it will update that column on ALL rows.
0
 
LVL 43

Assisted Solution

by:Eugene Z
Eugene Z earned 25 total points
ID: 38801609
<Since the field is Varchar do I just set the field to string '1/18/2013 4:41:00 PM' in my query>
yes ,it  is correct

in case you wish to store datetime

you can use CAST and CONVERT (Transact-SQL)
http://msdn.microsoft.com/en-us/library/ms187928(v=sql.100).aspx
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question