Solved

SQL - Update Statement Date Formatting

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

856 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