473,396 Members | 1,755 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,396 software developers and data experts.

problems with datepart in access

22
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="#dsn#">
SELECT datelisted
FROM listings
WHERE datepart('yyyy', datelisted) =#form.listedyear#
</cfquery>
That gets the year ok but if i try and add an AND datepart('mm', datelisted) =#form.listedmonth# 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 3564
nico5038
3,080 Expert 2GB
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
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.listedyear# and Month(datelisted) = #form.listedmonth#
Thanks very much
Jul 5 '08 #3
nico5038
3,080 Expert 2GB
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
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....
11
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...
3
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",) +...
1
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...
3
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...
2
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...
3
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...
24
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...
7
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...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.