Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Extracting date from a datetime column

Author  Topic 

Ali T
Starting Member

22 Posts

Posted - 2008-07-17 : 11:30:37
Dear all;
I have a table in sql server which contains a datetime column by the name of [datetime]. in this column i have both date and time as is clear. now i want to extract only the date part of this column and put it in a new column [date]. How can i handle this issue? please help me with this.
Kind regards
Ali T

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-17 : 11:38:33
use
UPDATE Table
SET [date]=DATEADD(d,DATEDIFF(d,0,[datetime]),0)
Go to Top of Page

Ali T
Starting Member

22 Posts

Posted - 2008-07-17 : 12:14:59
quote:
Originally posted by visakh16

use
UPDATE Table
SET [date]=DATEADD(d,DATEDIFF(d,0,[datetime]),0)



Dear visakh16
I checked it but unfortunately it did not work. Anyway i'm really thankful and waiting for more guides from you.
Ali T
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-07-17 : 12:20:20
what do you mean when you say it didn't work? if you mean you found that it still had the time but all 00:00:00.000 then it did work

Em
Go to Top of Page

Ali T
Starting Member

22 Posts

Posted - 2008-07-17 : 12:34:17
quote:
Originally posted by elancaster

what do you mean when you say it didn't work? if you mean you found that it still had the time but all 00:00:00.000 then it did work

Em



Dear friends
I checked it once again and found my mistake. it worked and I am really thankful!wow!
Ali T
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-17 : 12:34:17
quote:
Originally posted by Ali T

quote:
Originally posted by visakh16

use
UPDATE Table
SET [date]=DATEADD(d,DATEDIFF(d,0,[datetime]),0)



Dear visakh16
I checked it but unfortunately it did not work. Anyway i'm really thankful and waiting for more guides from you.
Ali T


why do you think it didnt work? Can you explain?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-17 : 12:34:49
quote:
Originally posted by Ali T

quote:
Originally posted by elancaster

what do you mean when you say it didn't work? if you mean you found that it still had the time but all 00:00:00.000 then it did work

Em



Dear friends
I checked it once again and found my mistake. it worked and I am really thankful!wow!
Ali T


cool
Go to Top of Page

Ali T
Starting Member

22 Posts

Posted - 2008-07-17 : 12:37:26
quote:
Originally posted by visakh16

quote:
Originally posted by Ali T

quote:
Originally posted by visakh16

use
UPDATE Table
SET [date]=DATEADD(d,DATEDIFF(d,0,[datetime]),0)



Dear visakh16
I checked it but unfortunately it did not work. Anyway i'm really thankful and waiting for more guides from you.
Ali T


why do you think it didnt work? Can you explain?


Dear visakh16
Thank you so much. that was my mistake. your quary was perfect.Thanks again
Ali T
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-17 : 12:38:53
quote:
Originally posted by Ali T

quote:
Originally posted by visakh16

quote:
Originally posted by Ali T

quote:
Originally posted by visakh16

use
UPDATE Table
SET [date]=DATEADD(d,DATEDIFF(d,0,[datetime]),0)



Dear visakh16
I checked it but unfortunately it did not work. Anyway i'm really thankful and waiting for more guides from you.
Ali T


why do you think it didnt work? Can you explain?


Dear visakh16
Thank you so much. that was my mistake. your quary was perfect.Thanks again
Ali T



There is no quary in SQL Server
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-18 : 04:42:10
<<
There is no quary in SQL Server
>>

It was another mistake

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -