Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 02, 2013 10:24 AM by Baiju EP
Member
178 Points
439 Posts
Feb 02, 2013 02:51 AM|LINK
in my asp.net web with vb code there is a code as under
qst = "SELECT sum(days) FROM lvedtl where type='CL' and No='" + pno.Text + "'"
i want to add one more clause in where year=getdate()
i had store year in varchar(10)
Star
9339 Points
1448 Posts
Feb 02, 2013 02:57 AM|LINK
Baiju EP qst = "SELECT sum(days) FROM lvedtl where type='CL' and No='" + pno.Text + "'"
qst = "SELECT sum(days) FROM lvedtl where type='CL' and No='" + pno.Text + "' and year = CAST(YEAR(GETDATE()) AS VARCHAR(10))"
EDIT: It is not tested...you may have to do some changes if you get any syntactical error.
Feb 02, 2013 04:05 AM|LINK
it picks even the year =2012 i want that if my cmptr current year is 2013 only the year=2013 should be counted and if there is no 2013 in year then it should not give any error as Conversion from type 'DBNull' to type 'String' is not valid
480 Points
148 Posts
Feb 02, 2013 06:57 AM|LINK
if you want to use clients pc date year.
than you should use a hidden filed. and get client pc year in this hidden filed and use
// jQuery $(document).ready( function () { checkClientTimeZone(); }
function checkClientTimeZone() {var dt = new Date(); document.getElementById("id_of_hiddenField").value=dt.getYear(); }
and use hiddenfield value except getdate();
thanks.
All-Star
36078 Points
7363 Posts
Feb 02, 2013 09:43 AM|LINK
WHERE [year]=Cast(year(getdate()) as varchar)
Feb 02, 2013 10:24 AM|LINK
THANKS IT WORKS FINE
Baiju EP
Member
178 Points
439 Posts
Add year part in query
Feb 02, 2013 02:51 AM|LINK
in my asp.net web with vb code there is a code as under
qst = "SELECT sum(days) FROM lvedtl where type='CL' and No='" + pno.Text + "'"
i want to add one more clause in where year=getdate()
i had store year in varchar(10)
me_ritz
Star
9339 Points
1448 Posts
Re: Add year part in query
Feb 02, 2013 02:57 AM|LINK
qst = "SELECT sum(days) FROM lvedtl where type='CL' and No='" + pno.Text + "' and year = CAST(YEAR(GETDATE()) AS VARCHAR(10))"
EDIT: It is not tested...you may have to do some changes if you get any syntactical error.
Baiju EP
Member
178 Points
439 Posts
Re: Add year part in query
Feb 02, 2013 04:05 AM|LINK
it picks even the year =2012 i want that if my cmptr current year is 2013 only the year=2013 should be counted and if there is no 2013 in year then it should not give any error as Conversion from type 'DBNull' to type 'String' is not valid
sudesh456
Member
480 Points
148 Posts
Re: Add year part in query
Feb 02, 2013 06:57 AM|LINK
if you want to use clients pc date year.
than you should use a hidden filed. and get client pc year in this hidden filed and use
// jQuery
$(document).ready( function () {
checkClientTimeZone();
}
function checkClientTimeZone()
{var dt = new Date();
document.getElementById("id_of_hiddenField").value=dt.getYear();
}
and use hiddenfield value except getdate();
thanks.
DotNetThreads |GharAshiyana |Pristine IT Solutions
oned_gk
All-Star
36078 Points
7363 Posts
Re: Add year part in query
Feb 02, 2013 09:43 AM|LINK
Suwandi - Non Graduate Programmer
Baiju EP
Member
178 Points
439 Posts
Re: Add year part in query
Feb 02, 2013 10:24 AM|LINK
THANKS IT WORKS FINE