Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Visual Studio Visual Basic Select Statement

Posted on 2007-03-22
4
211 Views
Last Modified: 2013-11-26
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
Comment
Question by:fsuedu
  • 3
4 Comments
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 18771609
try this convert(varchar(4), datepart(year, getdate()))
0
 

Author Comment

by:fsuedu
ID: 18771856
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
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 18771874
xt, 112)convert(va
            /\
no space??
0
 
LVL 21

Accepted Solution

by:
theGhost_k8 earned 500 total points
ID: 18771881
=
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb.net class 3 21
TimeZone, day light savings, Sql server, asp.net 6 37
transition to visual .net from vb6 5 39
Where does legacy ASP.NET initialize language? 2 24
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question