SQL QUERY FORMAT for TIME

Posted by Malli0403 under C# on 4/3/2013 | Points: 10 | Views : 997 | Status : [Member] | Replies : 7
How to pass the query of getting data from SQL sever by giving different times of TIME column...




Responses

Posted by: Jayakumars on: 4/3/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

use this 2 different Time

Firs-1
=========
SELECT convert(VARCHAR(8),getdate(),108)

Second
===============
SELECT convert(Time,getdate(),108)

Mark as Answer if its helpful to you

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

Posted by: Malli0403 on: 4/3/2013 [Member] Starter | Points: 25

Up
0
Down
pls help whts wrong in the below code...
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
DateTime dt1 = this.dateTimePicker1.Value;
string tstr1 = string.Format("{0:HH:mm:ss}",dt1);
}

private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
DateTime dt2 = this.dateTimePicker2.Value;
string tstr2 = string.Format("{0:HH:mm:ss}", dt2);

DateTime dt1 = this.dateTimePicker1.Value;
string tstr1 = string.Format("{0:HH:mm:ss}",dt1);


string tstrres = "SELECT TIME(TIME) FROM RAD_DETAILS WHEERE TIME='" +tstr1 +"BETWEEN"+ "AND TIME='" + tstr2 + "'";
this.Timeselected= tstrres;

// strSql = "Select Distinct(BOILERNO) BOILERNO From RAD_DETAILS WHERE TIME ='" + tstrres + "'";
//BindField(strSql, ref objDS, ref cmbBoilerNo, "BIO_DTL", "BOILERNO", "BOILERNO");
}


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

Posted by: Jayakumars on: 4/3/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

try convert your time and use this

SELECT TIME(TIME) FROM RAD_DETAILS WHEERE convert(VARCHAR(8),TIME,108)='" +tstr1 +"BETWEEN"+ "AND TIME='" + tstr2 + "'"

SELECT RIGHT(GETDATE(),8)AS TIMENOW

Mark as Answer if its helpful to you

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

Posted by: Malli0403 on: 4/3/2013 [Member] Starter | Points: 25

Up
0
Down
no its not working ..pls help me

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

Posted by: Jayakumars on: 4/3/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

malli post your code with zip format attachment section then i ill solved them.

Mark as Answer if its helpful to you

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

Posted by: Malli0403 on: 4/3/2013 [Member] Starter | Points: 25

Up
0
Down
code i am unable to attach..

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

Posted by: Jayakumars on: 4/3/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

post ur code server side and client side post here

Mark as Answer if its helpful to you

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

Login to post response