How to solve this Sql server Query [Resolved]

Posted by Jayakumars under Sql Server on 6/9/2015 | Points: 10 | Views : 302 | Status : [Member] [MVP] | Replies : 3
Hi
Bandi

How to solve this Query

SELECT ISNULL(CAST('2015-06-10' as varchar(20)),'')As CUDATE
here come my output this - 2015-06-10



But I need Exact Output 10-06-2015 how will do this

Mark as Answer if its helpful to you


Responses

Posted by: Bandi on: 6/9/2015 [Member] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
DECLARE @dateCol datetime = '2015-06-10' , @VarCol VARCHAR(100)= '2015-06-10'
SELECT CONVERT(VARCHAR(10), @dateCol, 105) AS [DD-MM-YYYY] ,
CONVERT(VARCHAR(10), @VarCol, 105) AS VarcharColumn,
CONVERT(VARCHAR(10), cast(@VarCol as datetime) , 105) AS VarcharColumnInDateFormat


output:
DD-MM-YYYY	VarcharColumn	VarcharColumnInDateFormat 
10-06-2015 2015-06-10 10-06-2015


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 6/9/2015 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
Bandi

Excellent.

Mark as Answer if its helpful to you

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 6/9/2015 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi
Bandi

another one







-- 1.I have give Starting Date and Ending Date Particular month
But I need shown the DayName Like This

for ex:-- from date :- 01-06-2015 To Date : 30-06-2015

Date DayName
01-06-2015 Monday
Continues
30-06-2015 Tuesday


2. When I select the monthname from my ddl i shown the query

i need output like this based on i select monthname

Date DayName
01-06-2015 Monday
Continues
30-06-2015 Tuesday




Mark as Answer if its helpful to you

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response