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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.