Displaying date through sql query?

R

ravi

hi friends,
can we display last ten dates from current system date using sql
query.
example todays date
19/4/2008 from this last 10 days
18/4/2008
17/4/2008
16/4/2008
'
'
'
9/4/2008
is this possible.
i dont have any table that give me dates.
i am working on SQl server.
 
T

ThatsIT.net.au

Not sure what you want to do

if you have these dates in a table then its

SELECT TOP 10 mydatefield FROM mytable

if you dont then

Dim dateArr(9)
For i = 0 To -9 Step -1
dateArr(Math.Abs(i)) = DateAdd(DateInterval.Day, i,
DateAndTime.Now)
Response.Write(DateAdd(DateInterval.Day, i, DateAndTime.Now))
Response.Write("<br>")
Next
 
B

bruce barker

simple query:

with foo (d , level)
as
(
select getdate(),1
union all
select dateadd(day,-level,d), level + 1
from foo
where level < 10
)
select d
from foo


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top