I used your approach (below) where you select All records matching some MAX(date). Then, I simply find the latest one out of those and get the USER_NAME from that record. It is much more reliable approach.
Thank you.
>OK, I'm pretty sure you won't want "max(user_name)", as I doubt that would hold any significance.
>
>I think I know the answer, but just to be sure, can post the relevant details for about 10 rows or so? (list them out, screen shot, whatever).
>
>Thanks
>
>>Hi Kevin,
>>
>>A follow up question, please. The MAX (CAST ....) approach works.
>>However, the table MyTable could have more than one record of the same Date (DateTimeField). And I want another field from the most recent record (e.g. USER_NAME). So, if I add to the SQL Select you suggested, the MAX(USER_NAME), will the SQL Select get the USER_NAME from the same record it gets from the MAX( CAST( DateTimeField))? Or the field/value from USER_NAME will be taken from ANY of the records of the same DateTimeField?
>>
>>Thanks.
>>
>>
>>
>>>SELECT MAX( cast( DateTimeField as Date)) from MyTable
>>>
>>>Now...if you want to find all the rows (i.e. transactions) that have that same date as the max date
>>>
>>>SELECT * from MyTransactions
>>>where cast( DateTimeField as date) = (SELECT MAX( cast( DateTimeField as Date)) from MyTransactions)
>>>
>>>
>>>
>>>>Hi,
>>>>
>>>>I am working on creating a SQL Select (against a SQL Server) to find a record with the most recent DATETIME field. But I am only concerned with the DATE portion of this DATETIME field (since the time is irrelevant). Here is a small pseudo example:
>>>>
>>>>select Date_Time from MyTable where Date_Time_Is_Most_Recent
>>>>
>>>>
>>>>TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham