Link to home
Start Free TrialLog in
Avatar of fsuedu
fsuedu

asked on

Visual Studio Visual Basic Select Statement

Hello All,

               Have this line of code below

Dim strSql As String = "SELECT Sum(fromadvtodaytxt) FROM Settlement Where SettlementDatetxt is not null and (CONVERT(Char(6), SettlementDatetxt, 112) = CONVERT(Char(6), GETDATE(), 112))"

Needing to add where it also checks the current year-if you can help?

Thanks JK
Avatar of theGhost_k8
theGhost_k8
Flag of India image

try this convert(varchar(4), datepart(year, getdate()))
Avatar of fsuedu
fsuedu

ASKER

Getting a syntax error

can you see whats wrong?

SELECT Sum(fromadvtodaytxt) FROM Settlement Where SettlementDatetxt is not null and (CONVERT(Char(6), SettlementDatetxt, 112) = CONVERT(Char(6), GETDATE(), 112)) and (CONVERT(varChar(4), SettlementDatetxt, 112)convert(varchar(4), datepart(year, getdate())))"

Thanks JK
xt, 112)convert(va
            /\
no space??
ASKER CERTIFIED SOLUTION
Avatar of theGhost_k8
theGhost_k8
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial