Microsoft
Software
Hardware
Network
Question : How to pass a variable into DATEADD function in SQL String
I have an application that uses sqlDataAdapter and datasets to get data for a VB.net application. From an SQL server database.
The data request is filtered by date - specifically "Get all rows where the student license expires in less than x days - 'x' being the varaible I want to pass into the SQL statement.
The where clause in the SQL string uses a DATEADD function.
Parameters with the SQLDataADapter do not seem to fit this scenario very well as they seem to need a column value to bind to in the SQL Stataement. So how do I pass a dynamic variable value into the DATE add function within the SQL.
The following snippet is far as I got when trying to use parameters:
sSql_Where = " And END_DT >= DATEADD(dd ,@DateCount, Date )"
Any help appreciated
Answer : How to pass a variable into DATEADD function in SQL String
Maybe it would be easier to do the date calculation in VB then build the where clause?
in vb:
dim DateCount as integer = x
dim CutoffDate as date = DateAdd(DateInterval.Day, DateCount , Date)
sSql_Where = " And END_DT >= " & CutoffDate
Random Solutions
Can't get checkbox to check if query criteria exists
Need help modifying query_post
Change the default image on a Windows Forms app in VB.NET
How to disable multitasking on iOS4 iPhone 3G ?
How to identify a Task (not process) on Applications tab in Task Manager and kill the assosiated process.
anyone see a reason why mysql would not fire and echo info(maybe a typo my luck)
Blocking unknown or private calls on iPhone 4
I need a C# ASP.NET commercial website that's mostly completed
Asterisk - Changing the Voicemail Naming Convention
Listbox question