|
 |
asp_databases thread: date problem in sql server
Message #1 by arshad siddiqui <ash_arshad@y...> on Sat, 31 Aug 2002 00:54:35 -0700 (PDT)
|
|
Hi All,
I have two things to ask.
first is what is sql statement to enter the current
date in the database.
second is the sql statement to get the latest date
from the database i.e if I want to dispaly only those
records which are last enterd.
Thank you
Best Regards
--Arshad--
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
Message #2 by Vijay G <happygv@y...> on Sat, 31 Aug 2002 12:42:47 -0700 (PDT)
|
|
Arshad,
For you 1st Question, try using
select getdate() ---- returns the current date.
if you want this to be specified as a default value, just give getdate() under the default heading for that column in table's design
view.
For the 2nd Question., try something like.
-----displays all the records that are entered in db in last 24 hrs. You can use this
-----only if you are sure that there will be atleast some entries in db for everyday.
Select * from TABLE_NAME where DATE_FIELD > getdate()-1
-----displays all the records that are entered in db in last 24 hrs. This returns
-----Top 10 RECENT records whichever are there in the db.
Select top 10 * from TABLE_NAME order by DATE_FIELD desc
Cheers!!!
Vijay G
arshad siddiqui wrote:Hi All,
I have two things to ask.
first is what is sql statement to enter the current
date in the database.
second is the sql statement to get the latest date
from the database i.e if I want to dispaly only those
records which are last enterd.
Thank you
Best Regards
--Arshad--
---------------------------------
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
|
|
 |