|
|
|
|
![]() ![]() |
Sep 7 2007, 12:15 PM
Post
#1
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 21 Joined: 15-August 07 Member No.: 48,203 |
i have a column in a table which is varchar format but contains timedate type data eg. '24/7/07 05:32 PM'. I'm trying to run a query which uses a where clause to only return the rows where this column is equal to the most recent date. I've tried using the MAX() function which returns a valid result but not the most recent date.
|
|
|
|
Sep 7 2007, 02:39 PM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 109 Joined: 5-September 07 From: Australia Member No.: 49,403 |
just keep refreshing the MAX it works for me and if that doesn't work, create a new table with this integrated into it and copy the data
|
|
|
|
Sep 30 2007, 01:46 AM
Post
#3
|
|
|
Newbie ![]() Group: Members Posts: 7 Joined: 30-September 07 Member No.: 50,874 |
i have a column in a table which is varchar format but contains timedate type data eg. '24/7/07 05:32 PM'. I'm trying to run a query which uses a where clause to only return the rows where this column is equal to the most recent date. I've tried using the MAX() function which returns a valid result but not the most recent date. Depends on the database you're using but most of them has a convertion function so you can convert from char to date, for example you can do in MS SQL "Select * from YourTableName where convert(char(10),DateAsVarcharInYourTable,101) = date()" or if you just need the last 10 records in you data you can also do "Select top 10 * from YourTableName order by convert(char(10),DateAsVarcharInYourTable,101) desc" in MySQL is a little bit more complicated, I can't remember the exact syntax but it will follow the same logic for the date translation, now why are you saving a date as varchar? just curious? |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th September 2008 - 09:05 AM |