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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Date

Status
Not open for further replies.

yakdogs

Programmer
Aug 13, 2002
40
US
I am rather new to SQL and could use a little help. This is my problem. I have a report that needs to pull up when it reaches the current date.

Meaning that the user enters a date and then in 60 days it pops up in their follow up items when it equals the current date.

This is the SQL stmt I have been working with.
(Convert(Char(8),tblMain.Last_FU + 60) = (Convert(Char(8), GetDate(), 101)

I don't know if I am approaching this correctly or not.

Can someone show me what I am doing wrong?
 
try using the dateadd() function.

Convert(Char(8),dateAdd(day, 60, tblMain.Last) = convert(Chr(8), GetDate(), 101)

Hope this helps

BB
 
but u should get the dates before your select, 'cause is better to perform

select * from tmytable where mDate >= 'xxx' and mDate <= 'yyy'

if u use convert in the where clause, the optimizer will go through all the table though an index exists.

regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top