• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

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
0
fsuedu
Asked:
fsuedu
  • 3
1 Solution
 
K VDatabase ConsultantCommented:
try this convert(varchar(4), datepart(year, getdate()))
0
 
fsueduAuthor Commented:
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
0
 
K VDatabase ConsultantCommented:
xt, 112)convert(va
            /\
no space??
0
 
K VDatabase ConsultantCommented:
=
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now