Click here to Skip to main content
15,900,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have migrated data from Ms Access to SQL Server 2008 where one of the field (ApplicationDate) is in datetime data type. in SQL Server 2008, i want it to be in date datatype only. The problem is, i want to remove the time part from date so after that i can convert the datatype. How can I do that?
this is the convert function that im going to use:
C++
CONVERT(varchar(20), Getdate(), 105)


The result that i look forward is:
from
C++
2011-05-08 00:00:00.000
becomes 08-05-2011(dd:mm:yyyy)
Posted
Updated 4-Aug-11 17:02pm
v2

 
Share this answer
 
Comments
snamyna 4-Aug-11 23:16pm    
thanks for the answer. but before i change the date format, i think i need to change the data first to date only. am i right? so how am i going to trim the time part from the date?
thatraja 4-Aug-11 23:20pm    
While changing the format(particular) it removes the portion too. For your req use SELECT convert(varchar, getdate(), 103) or SELECT convert(varchar, getdate(), 105), try that.
snamyna 4-Aug-11 23:23pm    
i did this before but it does not change the data, because it only takes effect when i want to view it. the data still as the same. i think i need to trim the date. but how?
thatraja 4-Aug-11 23:25pm    
Can you please share your code?
Hi
try this

SQL
select CONVERT (char(10),getdate(),101)



Thanks.
 
Share this answer
 
Ok..thanks everybody.. i have succeed! :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900