Date query

  • Thread starter Thread starter Bob Vance
  • Start date Start date
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")
 
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
 
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")
 
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!
 
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!
 
Back
Top