Jump to content

Get MAX Record


jjmusicpro

Recommended Posts

I have 2 columns in a database, date, and time

that looks like this

 

column 1    column 2

1/1/09      10:32AM

1/1/09      10:35AM

1/5/09      12:32AM

 

how can i write a query to get the latest phone call made ? i tried max but i didnt work.

I wanted it to get the latest time, for each day

Link to comment
https://forums.phpfreaks.com/topic/135538-get-max-record/
Share on other sites

That date format is not directly usable in comparisons or sorts... That time format is (assuming you always have leading zero's) because the string PM is higher in value than the string AM.

 

The DATETIME data type exists for a reason. It requires the least amount of storage space, it is directly usable in comparisons or sorts, and it results in the fastest operating queries because you don't need to manipulate the data to just find the values you are interested in.

 

Convert your system from using two separate varchar columns to use a single DATETIME column.

Link to comment
https://forums.phpfreaks.com/topic/135538-get-max-record/#findComment-706200
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.