Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 20th, 2011, 12:44 PM
Registered User
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with null date

Very new beginner here.

This is what I currently have:

Date Past 3 years: IIf([date]<Date()-1095,"Greater Than 3 Years","Less Than 3 Years"

for records where the date has been left blank it puts "Greater than 3 Years". I would like for it to say "no date entered".

The original field is set to date format.

any help would be greatly appreciated.

Thanks!

C
 
Old July 20th, 2011, 02:56 PM
Friend of Wrox
 
Join Date: Sep 2010
Posts: 245
Thanks: 5
Thanked 24 Times in 23 Posts
Default

First avoid naming fields the same name a reserved words. Using date as a field name will cause you many headaches.

To accurately get three years from a date use the DateAdd(). This will properly handle leap years. It will add or subtract from a date.


Example for subtracting three years:
Code:
DateAdd("yyyy", -3, Date() )
To test for a date in a date/time field use IsDate()

Example:
Code:
DatePast3years: IIf( IsDate([date]), IIF( [date]< DateAdd("yyyy", -3, Date() ),"Greater Than 3 Years","Less Than 3 Years"), "no date entered")
__________________
Boyd Trimmell aka HiTechCoach (.com)
Microsoft Access MVP Alumni 2010-2015





Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to update a date value to null pannasn .NET Framework 2.0 0 December 11th, 2007 06:47 AM
null date time dhoward VB.NET 2002/2003 Basics 1 June 15th, 2007 02:48 PM
behaviour of NULL value in date type columns kasanar SQL Server 2000 2 July 7th, 2005 04:40 PM
entering Null value for Date field jordancrandall Access ASP 1 January 12th, 2005 01:29 PM
Null Value for Date/Time Field ksegars4 Crystal Reports 2 November 17th, 2004 11:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.