Get most recent datetime from a table

sushmitha

Registered User.
Local time
Today, 17:13
Joined
Jul 30, 2008
Messages
55
I have a table with Invoice Number, State, State dt, State tmstp

State has 5 values like Delivered, spooled, prepared etc.

I need to get the the state of a invoice number with most recent date and time tmstp.

For ex: if I have 4 states for a invoice with different dates and time, I need to get the most recent or latest state of that invoice

How to write a query for this ??

Also need to convert the date time to mm/dd/yyyy hh:mm:ss
 
To convert the date time to mm/dd/yyyy hh:mm:ss, go to the desing view of your table and apply a format. I think this is Long Date found in the dropdown menue.
To get the state of the most recent, you would need to use the DMax function.

Assuming your Date Time field name is dteDateTime, your DMAX would be like this:

DMax("dteDateTime", "tblYourTable")

If you only want to do this in a query, then use this function as a criteria in your query.

But if you want this in a form, then you need VBA coding using the same function.




I have a table with Invoice Number, State, State dt, State tmstp

State has 5 values like Delivered, spooled, prepared etc.

I need to get the the state of a invoice number with most recent date and time tmstp.

For ex: if I have 4 states for a invoice with different dates and time, I need to get the most recent or latest state of that invoice

How to write a query for this ??

Also need to convert the date time to mm/dd/yyyy hh:mm:ss
 

Users who are viewing this thread

Back
Top Bottom