Showing posts with label reference. Show all posts
Showing posts with label reference. Show all posts

Monday, March 19, 2012

Newbie needs help with timestamp calculation

I'm a newbie, so please be gentle

I have a table that has a timestamp column that I can reference, e.g.,

SELECT *
FROM mytable
WHERE RECORDTIME < {TS '2006-05-01 00:00:00.000' }

This type of selection works.

What I want to do now is select the rows where the timestamp is less than 30 days prior to the current date instead of hardcoding a timestamp every time. I'm trying to select anything older than 30 days.

SELECT *
FROM myfile
WHERE RECORDTIME < [ current date's timestamp] - 30 days

I don't even know where to start so any help is greatly appreciated.

Thanks in advance,

Robert

I think I have it. This seems to work.

SELECT *
FROM myfile
WHERE RECORDTIME < ( cast( getdate() as datetime) - day(30) )

Please advise if you see anything that would be an issue.

Thanks!

|||

I don't think that it works exactly as the spec 'today less 30 days'.

Consider these two different results:

select getdate() - day(30), getdate()
select dateadd(day, -30, getdate()), getdate()

-- -
2006-04-30 15:44:45.890 2006-05-31 15:44:45.890

(1 row(s) affected)


-- --
2006-05-01 15:44:45.890 2006-05-31 15:44:45.890

(1 row(s) affected)

/Kenneth

Friday, March 9, 2012

Newbie for 2000 SQL Server

Dear All, I would like to know whether I can create a distributed database
by using SQL 2000 Server? If possible, any reference? Thanks alot!!The short answer is yes. The long answer is - what are you actually trying to
achieve as there are multiple ways to implement a "distributed database"

> Dear All, I would like to know whether I can create a distributed database
> by using SQL 2000 Server? If possible, any reference? Thanks alot!!

Neil Pike MVP/MCSE. Protech Computing Ltd
Reply here - no email
SQL FAQ (484 entries) see
http://forumsb.compuserve.com/gvfor...p?SRV=MSDevApps
(faqxxx.zip in lib 7)
or http://www.ntfaq.com/Articles/Index...epartmentID=800
or www.sqlserverfaq.com
or www.mssqlserver.com/faq|||Hi,

Refer sp_linkedservers T-SQL in SQL Books Online. Distirubted database
is called linked database. You can search for "Linked Server" keyword
in helps.
Also, refer SQL Server Enterprise monitor/Security/Linked Server
section.

Thanks Amit.

"Chris" <router88@.sinaman.com> wrote in message news:<bearmh$5ls2@.imsp212.netvigator.com>...
> Dear All, I would like to know whether I can create a distributed database
> by using SQL 2000 Server? If possible, any reference? Thanks alot!!