Real Software Forums
http://forums.realsoftware.com/

How to request latest db update from date/time field?
http://forums.realsoftware.com/viewtopic.php?f=3&t=48055
Page 1 of 1

Author:  tseyfarth [ Mon Jun 03, 2013 5:03 pm ]
Post subject:  How to request latest db update from date/time field?

Hello All,

Can anyone suggest the sql call to request the last update to a db? The db contains a field for Date and Time. I am having trouble getting my mind around the correct request call.

Thank you,
Tim

Author:  elChupete [ Mon Jun 03, 2013 5:34 pm ]
Post subject:  Re: How to request latest db update from date/time field?

Does every record contain a datetimefield when the record has been inserted / updated?

How is the date formated? In best case it is formated as sql date and each record has one.
Then something like

Select datetime from table order by date desc

Should do the trick.

The first record of the resulting record set isthe last date when a record was updated / inserted

You might also want to check the sql max function

Select max(datetime) from table

Author:  tseyfarth [ Mon Jun 03, 2013 6:01 pm ]
Post subject:  Re: How to request latest db update from date/time field?

Thank you.

Each record is updated/inserted with a SQLDateTime data string in the field.

I will also have a look at the Sql MAX function too.
Tim

Author:  J.Hansen [ Tue Jun 04, 2013 12:59 am ]
Post subject:  Re: How to request latest db update from date/time field?

tseyfarth wrote:
Hello All,

Can anyone suggest the sql call to request the last update to a db? The db contains a field for Date and Time. I am having trouble getting my mind around the correct request call.

Thank you,
Tim



For more informations, you might have a look on these two links:

http://www.w3schools.com/sql/sql_quickref.asp

http://www.tutorialspoint.com/mysql/index.htm

Author:  tseyfarth [ Tue Jun 04, 2013 1:34 am ]
Post subject:  Re: How to request latest db update from date/time field?

Thank you J. Hansen!

Tim

Author:  JeremK [ Tue Jun 04, 2013 3:18 am ]
Post subject:  Re: How to request latest db update from date/time field?

You could use this query:

Select * from mytable order by datefield desc limit 0, 1


This will select all fields from "mytable".
It will order the data on "datefield" column and take the highest value.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/