Date query

B

Bob Vance

I wanting to show the date as last day of the previous month from
[InvoivceDate] in my text box
=Format([InvoiceDate],"dd-mmm-yyyy")
 
J

Jeff Boyce

Bob

To get the last day of the previous month, there's a trick you can use with
the DateSerial() function. By using the "0" (zero-th) day of THIS month,
Access will determine the last day of last month.

Your expression might look something like:

DateSerial(Year(Date()), Month(Date(), 0)

This will use today's date (the Date() function) to get the year and month
of today's date, then step back to the last day of the previous month.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
B

Bob Vance

Thanks Jeff , can i use ([InvoiceDate]) for this code in my text box on a
Report
Regards Bob

Jeff Boyce said:
Bob

To get the last day of the previous month, there's a trick you can use
with the DateSerial() function. By using the "0" (zero-th) day of THIS
month, Access will determine the last day of last month.

Your expression might look something like:

DateSerial(Year(Date()), Month(Date(), 0)

This will use today's date (the Date() function) to get the year and month
of today's date, then step back to the last day of the previous month.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Bob Vance said:
I wanting to show the date as last day of the previous month from
[InvoivceDate] in my text box
=Format([InvoiceDate],"dd-mmm-yyyy")
 
J

John W. Vinson

Thanks Jeff , can i use ([InvoiceDate]) for this code in my text box on a
Report

If you want the last day of the month prior to InvoiceDate, use

=DateSerial(Year([InvoiceDate]), Month([InvoiceDate]), 0)

This will give September 30 if run on October 31... not clear if that's what
you want!
 
B

Bob Vance

Brilliant thanks John :)

John W. Vinson said:
Thanks Jeff , can i use ([InvoiceDate]) for this code in my text box on a
Report

If you want the last day of the month prior to InvoiceDate, use

=DateSerial(Year([InvoiceDate]), Month([InvoiceDate]), 0)

This will give September 30 if run on October 31... not clear if that's
what
you want!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top