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
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
try this convert(varchar(4), datepart(year, getdate()))
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
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??
/\
no space??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.