Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Problem With Where Clause And Max Function, Problem with where clause and max function
eskimmer
post 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.

Go to the top of the page
 
+Quote Post
benzkids
post 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
Go to the top of the page
 
+Quote Post
adiaz01
post Sep 30 2007, 01:46 AM
Post #3


Newbie
*

Group: Members
Posts: 7
Joined: 30-September 07
Member No.: 50,874



QUOTE(eskimmer @ Sep 7 2007, 08:15 AM) *
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?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. 60 Seconds Countdown That Shutdown The Pc(13)
  2. Problem Installing Sims 2 Nightlife(26)
  3. I Have A Girl Problem Here(27)
  4. Problem With Page Redirect(8)
  5. Php Header Problem(11)
  6. Dvd Drive Problem(10)
  7. Remote Assistance Problem(8)
  8. Laptop Keyboard Problem(7)
  9. Skype / Xampp Port Conflict(5)
  10. Two Lan Ports Problem(3)
  11. Rpg Maker 2003 Music Problem(3)
  12. I'm Having A Strange Problem With My Ping In Cs:s(28)
  13. I Have A Big Problem With Cs 1.6.(4)
  14. Need Help: Problem Seeing My Site(4)
  15. PHP Function To Add Previous and Next Page Feature(2)
  1. Forum Problem? Topic Disappeared Immediately [resolved](2)
  2. Hosting Problem [resolved](22)
  3. Problem Aligning In Firefox(9)
  4. It Went Well For A While(5)
  5. Itunes Problem!(1)
  6. How Many More Times Will I Have To Post About This?(11)
  7. Problem Getting Text To Align With Different Resolutions(4)
  8. Youtube People That Do Not Respect Other Opinions(7)
  9. A Problem With Ftp Clients(9)
  10. Domain Problem : This Is Important..(0)
  11. Browser Compatibility Problem With Firefox - Javascript + Css(3)
  12. Terminating Hosting Problem(1)
  13. Problem With My Girlfriend Family, Need Suggestions For Action(2)


 



- Lo-Fi Version Time is now: 5th September 2008 - 09:05 AM