Welcome to Dream.In.Code
Become an Expert!

Join 150,365 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,784 people online right now. Registration is fast and FREE... Join Now!




Help with query on timestamp field in mySQL

 
Reply to this topicStart new topic

Help with query on timestamp field in mySQL

nila
6 Feb, 2008 - 02:28 AM
Post #1

D.I.C Head
**

Joined: 5 Jan, 2008
Posts: 128

Hi,
I am having a field "lastupdated " in my table "test".the type is timestamp.I want to select all records from the test according to the time which is updated atlast.I dont know how to write the query.

help me please.
Thanks.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Help With Query On Timestamp Field In MySQL
6 Feb, 2008 - 12:24 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,327



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Moved to Databases forum.
User is online!Profile CardPM
+Quote Post

PsychoCoder
RE: Help With Query On Timestamp Field In MySQL
6 Feb, 2008 - 05:04 PM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
You could use mySQL's DATE_FORMAT Function to convert your timestamp to a date, something like:


SQL
SELECT DATE_FORMAT(lastupdate, '%c %d %y') AS last_updated FROM test



This will return a date, such as 10/13/08. For a date in the format of 10/13/2008 use


SQL
SELECT DATE_FORMAT(lastupdate, '%c %d %Y') AS last_updated FROM test



Hope this helps & happy coding! smile.gif


User is offlineProfile CardPM
+Quote Post

nila
RE: Help With Query On Timestamp Field In MySQL
7 Feb, 2008 - 10:33 PM
Post #4

D.I.C Head
**

Joined: 5 Jan, 2008
Posts: 128

Hi, thanks for your reply.
But i dont need to get the date.I want to retreive the records which is currently (atlast)updated.for that only i am using the time.


User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Help With Query On Timestamp Field In MySQL
7 Feb, 2008 - 10:40 PM
Post #5

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
To get the time use

SQL
SELECT DATE_FORMAT(lastupdate, '%h %i') AS last_updated FROM test



Had you read the link I provided you it would show you all the possible combinations to get what you are looking for from a timestamp field smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 01:56PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month