Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 October 12th, 2004, 04:01 PM
Authorized User
 
Join Date: Jun 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Omit negative values in Queries - Access 97

This is driving me nuts!! how do you omit negative values in Access.

Specifically,

I'm calculating the days between dates. However, if value1 is later than value 2, the diffdate returns a negative value. I need to omit the negative values (or maybe return some sort of value like '0' or something.)

Help!!

Thanks a bunch.

 
Old October 13th, 2004, 12:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To omit lines with negative values:

SELECT Table1.Value1, Table1.Value2, DateDiff("d",[Value1],[Value2]) AS Expr1
FROM Table1
WHERE (((DateDiff("d",[Value1],[Value2]))>=1));

To convert negative numbers to zero:

SELECT Table1.Value1, Table1.Value2, IIf(DateDiff("d",[Value1],[Value2])>=0,DateDiff("d",[Value1],[Value2]),0) AS Expr1
FROM Table1;

Hope this helps.


Clive Astley





Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to omit the duplicate values when displayin ppakala XSLT 1 June 24th, 2008 06:13 PM
Access 2000 to Access 97 happygv Access 5 April 23rd, 2004 10:06 AM
Access 97 Benwaa Access VBA 0 January 28th, 2004 02:37 PM
Migrating from access 97 to access 2000 Khalifeh Access 12 October 2nd, 2003 02:54 PM
Listboxes In Access 97 timmaher Access VBA 6 June 9th, 2003 03:53 AM





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