?
Solved

SQL - Update Statement Date Formatting

Posted on 2013-01-21
2
Medium Priority
?
328 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 700 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 100 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Suggested Courses

752 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