A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Date Calculation and Formatting



 
 
Thread Tools Display Modes
  #1  
Old May 25th, 2004, 09:21 PM
Chris
external usenet poster
 
Posts: n/a
Default Date Calculation and Formatting

Have a form based on a query to calculate an expiration date. WarrantyMonths is a number field. InvoiceDate is a date field. I’ve written the following expression to the query

ExpiresDate: IIf(IsNull(VehicleServiceDetails!WarrantyMonths)," ",DateAdd("m",[WarrantyMonths],[InvoiceDate]))

However, if I try to sort the ExpiresDate, the results appear to sort by month and day only, not month, day and year.

Eg results of sort ascending:
ExpiresDate

03/20/2004
04/28/2005
06/09/2004
06/11/2004
06/11/2004
06/19/2004
08/20/2004
10/23/2004
12/10/2002

Additionally, I would like to use conditional formatting to flag unexpired warranties with green. If I set the form control DateExpires to

Field Value Is Greater than or equal to Date() The 04/28/2005 record shows as expired and the 12/10/2002 record shows as unexpired. Any assitance is appreciated.

Thank you,
Chris
  #2  
Old May 25th, 2004, 10:32 PM
Chris Nebinger
external usenet poster
 
Posts: n/a
Default Date Calculation and Formatting

I think the problem is that Access isn't seeing the field=20
as being a date. Try:

iif(IsNull(WarrantyMonths),Null,
DateAdd("m",[WarrantyMonths],[InvoiceDate]))


Chris Nebinger




-----Original Message-----
Have a form based on a query to calculate an expiration=20

date. WarrantyMonths is a number field. InvoiceDate is a=20
date field. I=E2?Tve written the following expression to=20
the query =20

ExpiresDate: IIf(IsNull(VehicleServiceDetails!

WarrantyMonths),"",DateAdd("m",[WarrantyMonths],
[InvoiceDate]))

However, if I try to sort the ExpiresDate, the results=20

appear to sort by month and day only, not month, day and=20
year. =20

Eg results of sort ascending:=20
ExpiresDate

03/20/2004
04/28/2005
06/09/2004
06/11/2004
06/11/2004
06/19/2004
08/20/2004
10/23/2004
12/10/2002

Additionally, I would like to use conditional formatting=20

to flag unexpired warranties with green. If I set the=20
form control DateExpires to=20

Field Value Is Greater than or equal to Date() The=20

04/28/2005 record shows as expired and the 12/10/2002=20
record shows as unexpired. Any assitance is appreciated. =20

Thank you,
Chris
.

  #3  
Old May 25th, 2004, 10:51 PM
Chris
external usenet poster
 
Posts: n/a
Default Date Calculation and Formatting

That did it. Thank you!
Chris
  #4  
Old May 26th, 2004, 12:15 AM
fredg
external usenet poster
 
Posts: n/a
Default Date Calculation and Formatting

Chris,

The IIf(IsNull([FieldName]),"" part is causing Access to sort the
field as though it were text. Try it this way:
ExpiresDate:
IIf(IsNull(VehicleServiceDetails!WarrantyMonths),[WarrantyMonths],Date
Add("m",[WarrantyMonths],[InvoiceDate]))

Since [WarrantyMonths] is null nothing will show anyway.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.

On Tue, 25 May 2004 13:21:07 -0700, Chris wrote:

Have a form based on a query to calculate an expiration date.
WarrantyMonths is a number field. InvoiceDate is a date field.
I¢ve written the following expression to the query

ExpiresDate: IIf(IsNull(VehicleServiceDetails!WarrantyMonths)," ",Dat
eAdd("m",[WarrantyMonths],[InvoiceDate]))

However, if I try to sort the ExpiresDate, the results appear to
sort by month and day only, not month, day and year.

Eg results of sort ascending: ExpiresDate

03/20/2004 04/28/2005 06/09/2004 06/11/2004 06/11/2004 06/19/2004
08/20/2004 10/23/2004 12/10/2002

Additionally, I would like to use conditional formatting to flag
unexpired warranties with green. If I set the form control
DateExpires to

Field Value Is Greater than or equal to Date() The 04/28/2005
record shows as expired and the 12/10/2002 record shows as
unexpired. Any assitance is appreciated.



Thank you, Chris

  #5  
Old May 26th, 2004, 03:41 PM
Chris
external usenet poster
 
Posts: n/a
Default Date Calculation and Formatting

Fred,
Your solution works also. Thank you!
Chris


 




Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:11 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.