Click here to Skip to main content
15,899,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends.,

here I have an query which needs to pick up the complaint number which was not solved within the time frame like 6hours from the time that complaint was registered, and here i have 4coloumns saying compdate,comptime,forwardeddate,forwardedtime which are of nvarchar data type in the table urbrur means urban rural.

So for this from the net i found one query i.e,
SQL
"select compno from urbrur where forwardedtime>DATEADD(hour,6,@time)";  

for that @time they used some fixed date time like
SQL
Set @Time='09/16/2011 10:00:00'

but here i can't use it because as in my table the date and time are in separate columns having datatype i.e, nvarchar and I don't want this type of fixed values, it should take the values from the date n time columns in the database . .

So friends i think i gave an complete descrption to my query so kindly do concerned to my problem and give favorable reply

I'm very thankful to u all,
praveen
Posted
Updated 21-Sep-11 0:26am
v2
Comments
Om Prakash Pant 21-Sep-11 7:02am    
any specific reason for creating date fields as nvarchar?
(compdate,comptime,forwardeddate,forwardedtime)
praveengb 21-Sep-11 8:23am    
I'm inserting it as TextBox34.Text.ToString()in the insert query

if date and time are in separate columns, then you need to concatinate the columns, convert to datetime and then use the datetime function. something like:


SQL
select compno from urbrur where 
cast(forwardeddate + ' ' + forwardedtime as datetime) > DATEADD(hour,6,@time)

(assuming that the columns will have date and time in actual formats),
 
Share this answer
 
Comments
praveengb 22-Sep-11 1:31am    
but friend whats that @time, I don't have any column or variable declared by this name....
but friend whats that @time, I don't have any column or variable declared by this name....
 
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