[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Remove hour/min/second from date

Posted on 2007-08-06
3
Medium Priority
?
231 Views
Last Modified: 2013-11-05
I would like to remove the following time element. How would I update it.

6/27/2007 9:00:  >>>>>  to display as 6/27/06
 7/1/2007  7:00 :34 >>>> 7/1/2007
4/2/2007 5:20:45>>>>> 4/2/07
0
Comment
Question by:zachvaldez
  • 2
3 Comments
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 400 total points
ID: 19643470
Hello zachvaldez,

SELECT CONVERT (Varchar, urDateColumn,101)
Eg

SELECT CONVERT(VARCHAR,GETDATE(),101)



Aneesh R
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 400 total points
ID: 19643513
> How would I update it.
if it is a datetime column, you can't remove the time part, what you can do is, can update those min/secs to zero

update urTable
SET urDateColumn = CONVERT(VARCHAR,urdateColumn,112)

in case you dont want to show the time portions, you can use the above query


0
 
LVL 42

Accepted Solution

by:
dqmq earned 600 total points
ID: 19643702
To remove the time component from a datetime column:

update YourTable
set YourDate = convert(datetime,convert(varchar(10),YourDate,101),101)
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Suggested Courses

872 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