Solved

SQL Server 2008 Problems altering data type to Date

Posted on 2011-02-17
5
377 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
  • 2
  • 2
5 Comments
 
LVL 51

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:ewangoya
ID: 34921940
use alter column

ALTER TABLE TABLENAME
ALTER COLUMN CALLDATE DATE
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

16 Experts available now in Live!

Get 1:1 Help Now