[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SQL Server 2008 Problems altering data type to Date

Posted on 2011-02-17
5
Medium Priority
?
419 Views
Last Modified: 2012-05-11
I have a very large table [MasterFinal] and it includes a column that has a datetime type named CallDate
There is also a Calltime field so I would like to Alter the CallDate to type Date like 01/01/2011
Can someone help me?
0
Comment
Question by:Mswetsky
[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
  • 2
5 Comments
 
LVL 60

Expert Comment

by:HainKurt
ID: 34920213
CallDate is already datetime! you want to remove time part?
do you want to convert it to date only? and put time part into Calltime?
do you have values in CallTime now? or is it empty...

\can you give a sample and tell us what are you trying to do here...
0
 
LVL 1

Author Comment

by:Mswetsky
ID: 34921082
I don't want to involve the Time column.
I was looking for a data type to cut the Datetime field down.
Is there a way to Alter Column?
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34921940
use alter column

ALTER TABLE TABLENAME
ALTER COLUMN CALLDATE DATE
0
 
LVL 60

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 34922810
here is the steps:

create table dt(
a int,
b datetime,
c time)

insert into dt(a,b) values (1,getdate()-0.745)
insert into dt(a,b) values (2,getdate()-0.123)
insert into dt(a,b) values (3,getdate()-0.445)

select * from dt

a      b      c
1      2011-02-17 03:24:27.230      NULL
2      2011-02-17 18:20:08.030      NULL
3      2011-02-17 10:36:27.230      NULL

update dt set c=b

select * from dt

a      b      c
1      2011-02-17 03:24:27.230      03:24:27.2300000
2      2011-02-17 18:20:08.030      18:20:08.0300000
3      2011-02-17 10:36:27.230      10:36:27.2300000

alter table dt alter column b date

select * from dt

a      b      c
1      2011-02-17      03:24:27.2300000
2      2011-02-17      18:20:08.0300000
3      2011-02-17      10:36:27.2300000
0
 
LVL 1

Author Closing Comment

by:Mswetsky
ID: 34926604
Thanks
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 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