Click here to Skip to main content
14,927,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
i need to convert date format
2012-11-15 into 15-Nov-2012, we need to convert datetime into datetime not using varchar and char using sql server...,


condition:
need to convert datetime into datetime.


Regards
siva
Posted

Take date ouput in both ways.
SELECT CONVERT(VARCHAR(9), GETDATE(), 6) StringDate,
       GETDATE()  RegularDate


In gridview column where you are displaying date just change SortExpression to RegularDate & while displaying use StringDate

XML
<asp:BoundField SortExpression="RegularDate" />
    <asp:TemplateField SortExpression="RegularDate"></asp:TemplateField>
   
SELECT CONVERT(VARCHAR(9), GETDATE(), 6)

Try this, hope you found your solution.
   
Comments
Member 3962514 1-Aug-12 4:22am
   
SELECT REPLACE(CONVERT(varchar(50), GETDATE(), 106), ' ', '-')

if i use above querry i can get 01-Aug-2012
but i dont want to use char and varchar i need to display its like a datetime
after converting.
pradiprenushe 1-Aug-12 4:27am
   
What is problem with varchar?
Member 3962514 1-Aug-12 4:34am
   
actually my problem is i need to return date format like 01-Aug-2012
in this value should not be varchar or char.
why because of while i am retriving it from the c# win application.
i am bind into the datagridview, so in that grid if we select the column
i mean the date column it should be sorting

case 1:
if i pass its like ur querry its taking as sting(date values)
so it sort my string like below,

01-May-2012
02-Aug-2012
02-May-2012
like that
so if i return the date format it will be work i guess.

or give some suggestion....

Regards
Siva
pradiprenushe 1-Aug-12 4:43am
   
Try my 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