Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 17th, 2006, 05:32 AM
uknxs2 uknxs2 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 28 uknxs2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 22 m 8 sec
Reputation Power: 0
Date problem in Access query

Hi,

Am running the code below, however for some reason it's not selecting the correct records from access, ie. it's messing up the dates...

What am I doing wrong?

Thanks!


Dim Ddate as Date
DDate = "11/08/2006"

Dim nb1W as Date
Dim nb1M as Date

nb1W = DDate + 7
nb1M = DDate + 31

Dim strSelect1W as String
Dim strSelect1M as String

strSelect1W = "Select * into Z from X where Y < #" & nb1W & "#;"

strSelect1M = "Select * into Z from X where Y > #" & nb1W & "# and Y <= #" & nb1M & "#;"

DoCmd.RunSQL strSelect1W
DoCmd.RunSQL strSelect1M

Reply With Quote
  #2  
Old August 17th, 2006, 10:06 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 1,932 sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 22 h 34 m 58 sec
Reputation Power: 1243
Hi,

I think your problem is caused by the fact that you cant just add a number to a date in the same way as you would an integer. You need to use the dateadd function.
Code:
Dim Ddate as Date
DDate = "11/08/2006"
Dim nb1W as Date
Dim nb1M as Date
nb1W = DateAdd("d", 7, DDate)
nb1M = DateAdd("M", 1, DDate)

Do a Google search for the DateAdd Function for a full explanation. Also, DateDiff may be of use to you if you ever need to compare two dates!!!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Date problem in Access query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT