Solved

SQL - Update Statement Date Formatting

Posted on 2013-01-21
2
326 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

734 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