473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Year(Date()) not working as expected

I'm trying to run a query that will show only records where the year in a
date field equals the current year:

SELECT tblSideJob.SideJobID, tblSideJob.Date FROM tblSideJob WHERE
(((tblSideJob.Date)=Year(Date())));

This does not display any records at all. The field tblSideJob.Date is a
date/time field
Jan 29 '07 #1
1 6591
On Mon, 29 Jan 2007 00:17:29 GMT, Jimmy wrote:
I'm trying to run a query that will show only records where the year in a
date field equals the current year:

SELECT tblSideJob.SideJobID, tblSideJob.Date FROM tblSideJob WHERE
(((tblSideJob.Date)=Year(Date())));

This does not display any records at all. The field tblSideJob.Date is a
date/time field
1) That's because Year(Date()) does not return a Date datatype value,
but rather a variant (Integer) datatype value, i.e. 2007 is not a
date. See VBA help.

Change the Where clause to:

WHERE Year(tblSideJob.Date)=Year(Date())

2) Date is a reserved Access/VBA/Jet word and should not be used as a
field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jan 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
3
by: Jason S | last post by:
Hello Group, I am just about tearing my hair out with this one and thought someone may have some insight. I have a transform that wasn't working so I grabbed the nearest debugger (xselerator)...
0
by: Sameers (theAngrycodeR) via .NET 247 | last post by:
I think I will get MAD very soon. Its very weired problem I amfacing here. Let me explain. I have two DBF files from which I want to export data in CSVformat. I created a desktop application and...
10
by: Scott Richards | last post by:
Hi I am getting a exception while using a datareader here is the code Me.SqlConnection1.Open() Me.SqlReservationCheck.Parameters("@Ref").Value = Ref Dim Reader As SqlClient.SqlDataReader = _...
8
by: WvH | last post by:
Hi, When I create a new application, with just one button, then this code works as expected: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
4
by: Kiyomi | last post by:
Hello, I am trying to replace my alert message box with a popup page. In my page behind,
4
by: Jeff | last post by:
I feel like I should have been able to figure this out but I can't seem to find any references on this topic. It seems like my current working directory is consistently a few directories up from...
2
by: Trevor | last post by:
Argh! This problem is driving me nuts! Can you help? In November of 2003, I installed a web service on Windows Server 2003 built in VB.NET for v1.1.4322 of the framework. It contains a timer...
3
by: Brad Baker | last post by:
I have a formview with a datasource that contains a select and update command. The select statement works fine but the update command doesn't seem to be working. After some troubleshooting I have...
13
by: johneecc | last post by:
Hi, I am having a heck of a time trying to figure this one out. I am not a pro with CSS or ASP. I know VBScript fairly well. There is a Expected ')' error in the line with the "a href"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.