Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

T-SQL question

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi All

Is it possible to do a query which will use today's date, something like :-

select * from StoryDetails
where receivedDateTime = <today>
order by receivedDateTime

receivedDateTime contains the Time aswell as the date.

Many thanks for help
lou
 
You can use the Sybase getdate() function to return the current date. Be careful though as you may have problems in where clauses because of the HH:MM component of the returned value.

Greg.

 
You'll need to use a BETWEEN from 00:00:00 on <date> and 23:59:59 (not midnight again as that would also get picked up on the next date). Look at the CONVERT function - you'll need it!

If you're always looking for stuff added on today's date, you could use receivedDateTime >= CONVERT(datetime, CONVERT(varchar(20), 106*, getdate()))

* or any style that excludes time.

HTH,

Mike
 
Hi,
If time is not of any concern in the query you may use the 112 format for date. 112 will express the date in yyyymmdd format and will be easy to order by.

Thanks

Somnath
 
Pls, help
I want to display system date decrement by 1 day using
query like &quot; select getdate()-1&quot;
how can I?
 
Hi Manoj,

1> select dateadd(dd,-1,getdate())
2> go

--------------------------
May 9 2002 3:50PM

(1 row affected)

Regards

Somnath
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top