473,657 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problems with datepart in access

22 New Member
Hi Peoples
I am having probs with the datepart function with a query.What i want is to get all listings made in any month in any year ie May 2007
i have 2 drop down boxes to select the listedmonth and listedyear on the refering page
I need to be able to retrieve this so i can send out renewals to those listings for another year.
I am using this query
<cfquery name="getrenew" datasource="#ds n#">
SELECT datelisted
FROM listings
WHERE datepart('yyyy' , datelisted) =#form.listedye ar#
</cfquery>
That gets the year ok but if i try and add an AND datepart('mm', datelisted) =#form.listedmo nth# to the where statement i get the following error

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'datepart('yyyy ', datelisted) =2007 AND datepart('mm' datelisted)=07' .

How can i get this to work please
cheers and thanks in advance
Grabit
Jul 5 '08 #1
3 3607
nico5038
3,080 Recognized Expert Specialist
I would use the Year() and Month() function to achieve this like:
Expand|Select|Wrap|Line Numbers
  1. WHERE Year(datelisted) = " & form.listedyear & " and Month(detelisted) = " & form.listedmonth
  2.  
Getting the idea?

Nic;o)
Jul 5 '08 #2
grabit
22 New Member
I would use the Year() and Month() function to achieve this like:
Expand|Select|Wrap|Line Numbers
  1. WHERE Year(datelisted) = " & form.listedyear & " and Month(detelisted) = " & form.listedmonth
  2.  
Getting the idea?

Nic;o)
Thanks heaps Nic i had to make a few changes for the coldfusion type code but this works perfectly.
WHERE Year(datelisted ) = #form.listedyea r# and Month(dateliste d) = #form.listedmon th#
Thanks very much
Jul 5 '08 #3
nico5038
3,080 Recognized Expert Specialist
Glad I could help, success with your application !

Nic;o)
Jul 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
6296
by: David | last post by:
Hi Group, i am trying to use the DatePart function on my SQL2000 database. I have a table called visitors with a field called DateTimeEntrance which is filled everytime a visitor enters the site. I am trying to build a stat page where i display the total amount of visitors per day, week, month, year and i can't seem to get the syntax correct. I get an error with the following code: sql = "SELECT * FROM tblVisitors WHERE...
11
2147
by: brian.newman | last post by:
I'm trying to use a layer inside a form to hide/reveal a part of the form, but my code doesn't seem to be working and I need some help debugging it. I'm not getting an error which has made it difficult to debug the code, but I am getting the alert ("break 4 in getStyleObject"); which makes me think this is a browser compatability issue (I'm running IE 6.0). Anyway, the code follows function getStyleObject (objectId) { alert ("begin...
3
12580
by: david liu | last post by:
i have a date (in date/time format with input mask) in access 2002. field date: 01/01/1970 what i want: 010170 (i.e. mmddyy) i used: DatePart("m",) + DatePart("d",) + right(DatePart("yyyy",), 2) and i get: 1170
1
1661
by: sean | last post by:
Hi All, I have one table TABLE1 in access2k on machine PC1, that has one column named DO_DATE with "Date/Time" data type. Two other machines PC2 and PC3 also running access2k. Each PC has its own data entry form, and each form would execute the following insert query independently: INSERT INTO TABLE1 (DO_DATE, ... ) SELECT DatePart("m",.) & "/" &
3
6932
by: haydn_llewellyn | last post by:
Hi, My company runs on a fiscal calendar that starts on the first monday in July, and is based on a 13 week quarter (4 weeks, 4 weeks, 5 weeks). What I need, is a way of relating Date() to the actual fiscal month (e.g. today is 01/07/05, and is the last day in June in our fiscal calendar). I tried many methods, and had hoped that DatePart() with the 'ww' flag and DatePart() with the 'w' flag (to choose the first monday in July,
2
2126
by: le0 | last post by:
Hello guys, Is there anything wrong with my code (see below) bcoz when 10p-6a shift my browser returns the error cannot be a zero-length string. Im wondering why, bcoz the 2 other shift works perfectly. <% 'Shift: 6a-2p if DatePart("h", Now()) 5 And DatePart("h", Now()) < 14 then ShiftID = "A"
3
3215
by: rn5a | last post by:
In my local computer, date has been set in this format - dd/MM/yyyy. When I insert records in a MS-Access DB table using ASP.NET, then the records get inserted in the Access DB table exactly in the same format as what has been set in my local machine. For e.g. if today is 21st February 2007 & the time is 10:45:32 AM, then this record gets inserted in the Access DB table as 21/02/2007 10:45:32 AM But when I try to insert the same...
24
2019
by: rn5a | last post by:
The date in my local machine is set to the dd/MM/yyyy format. When I insert a date in a MS-Access DB table, it gets populated in the above format. For e.g. if the date is, say, 8th March 2007, it gets populated in the DB table as 08/03/2007 In other words, first the day is shown, then the month & finally the year but when I retrieve it in ASP.NET & using DatePart, try to extract the day & the month like this (assume that the date...
7
2820
by: tasmontique | last post by:
I have an access table that outputs to excel using a query . However what I am trying to do is under the arrival date column specify a criteria based on the Datepart function that only displays output based on specific day of week. I want query to check the stored date in the arrival column and based on that date that is examined by the date part function only return rows based on day of week .Here is my sql. SELECT...
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.