Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Today's date/Changed

Author  Topic 

Tiger
Starting Member

5 Posts

Posted - 2006-03-19 : 12:24:33
Okay, 2 questions here.

First I want to query everyone with a date greater than today in the field EXPIRATION DATE. I know I can say > 2006-03-19 but I always want it to be TODAY.

Next, Is there a system field that I can search for the date a record was last updated?? I make frequent changes, and I want others to see what date a record was last updated. If not, can I tell the system to mark a field "YES" when I make changes?

I use phpmyadmin. I do not have server access, just through PHP.

Thanks!
TV

...The TIger has ROARED

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-03-19 : 12:28:23
1. today = getdate()
2. no there isn't. if you want that functionality you have to add the column last_updated in your tables and update it eiter with a trigger or in a sproc that you use for accessing data.


Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-20 : 00:19:01
1 Select columns from yourTable where datecol>DateAdd(day,Datediff(day,0,getdate()),0)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Tiger
Starting Member

5 Posts

Posted - 2006-03-20 : 22:49:52
SELECT * FROM `MTIA` WHERE `Expires` >DateAdd(day,Datediff(day,0,getdate()),0)

Gets me nothing. I tried putting 'dateadd....' and get nothing. :-( Sorry, I'm SQLtupid. :-/

...The TIger has ROARED
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-03-20 : 22:53:38
does this return anything ?
select * from MTIA where Expires > '20060319' 




KH

Choice is an illusion, created between those with power, and those without.
Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant

Go to Top of Page

Tiger
Starting Member

5 Posts

Posted - 2006-03-21 : 00:39:29
Select * from MTIA where Expires>DateAdd(day,Datediff(day,0,getdate()),0)

SQL query:

SELECT *
FROM MTIA
WHERE `Expires` > DateAdd(DAY , Datediff(DAY , 0, getdate()), 0)

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( day , Datediff ( day , 0 , getdate ( ) ) , 0 ) LIMIT 0, 30' a


...The TIger has ROARED
Go to Top of Page

Tiger
Starting Member

5 Posts

Posted - 2006-03-21 : 00:40:28
does this return anything ?

select * from MTIA where Expires > '20060319'

Gives me just what I want! But only til midnight. :-)

...The TIger has ROARED
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-21 : 00:57:23
>>MySQL said:

Do you use MySQL?
This is for SQL Server.


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Tiger
Starting Member

5 Posts

Posted - 2006-03-21 : 05:54:03
I use phpmyadmin. I do not have server access, just through PHP.

It is MySQL in the background

...The TIger has ROARED
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-03-21 : 05:56:54
well this sql server forum... so not many people have worked with mysql
have you tried dbforums?
http://www.dbforums.com/f5

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-21 : 06:48:33
Also try at www.Mysql.com

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -