Solved

SQL - Update Statement Date Formatting

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

Assisted Solution

by:EugeneZ
EugeneZ 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now