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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 date help

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2006-06-05 : 05:01:18
how can I select all records where the date is within the last half hour.

select * from users where dateentered<getdate()-???

Also
within a stored procedure can I do somehting like this

if mysting like 'testing%' then
/*do nothing */
else
select @ok=1


Is that valid to do?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-06-05 : 05:07:24
> dateadd(n, -30, getdate())

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-06-05 : 05:50:51
quote:
Also
within a stored procedure can I do somehting like this

if mysting like 'testing%' then
/*do nothing */
else
select @ok=1

Yes!...

declare @mystring varchar(20), @ok bit
set @mystring = 'not testing'

if not @mystring like 'testing%'
set @ok = 1

select @ok


Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-05 : 07:10:34
quote:
Originally posted by spirit1

> dateadd(n, -30, getdate())

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]



Just for clarity, I prefer using

dateadd(minute, -30, getdate())

Madhivanan

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

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-06-05 : 08:31:39
i prefer less typing

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-06-05 : 09:00:40
And I do not prefer one over the other

Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-05 : 09:04:53
quote:
Originally posted by RyanRandall

And I do not prefer one over the other

Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.


So, what do you prefer?

Madhivanan

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

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-06-05 : 09:15:09
I prefer to sit on the fence



Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-05 : 09:21:53
For me, I will go for Madhivanan's method.


KH

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-06-05 : 09:24:40
i'll go with ryan's
i like his...

Go with the flow & have fun! Else fight the flow
Blog thingie: [URL="http://weblogs.sqlteam.com/mladenp"]
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-06 : 01:57:09
i like sitting on a fence, and on top of my table, and on top of my car, and on the 2nd deck of a bus...



--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-06 : 04:35:45
quote:
Originally posted by jen

i like sitting on a fence, and on top of my table, and on top of my car, and on the 2nd deck of a bus...



--------------------
keeping it simple...


Where are you now Jen? Homeland or Singapore

Madhivanan

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

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-06 : 04:48:16
still in the land of the durian ampitheater

how about you Maddy, are you in India or somewhere else?

--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-06 : 05:05:55
in India

Madhivanan

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

- Advertisement -