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!

Display only upcoming dates! (urgent)

Status
Not open for further replies.

NEL3644

Technical User
Sep 4, 2000
26
US
In a field called StartDate in one of my DB tables I have dates entered with the following format: 20000128 (year,month and date respectively)...and I want to compare w/ the system date ( #CreateODBCDate(now())# ) which has the following format: {d '2000-11-02'}

I have tried the query below, but it seems like it's not able to compare 20000128 from {d '2000-11-02'}:

select * from Date
where StartDate >= #CreateODBCDate(now())#

My main goal is to be able to ignore dates before the current date and display only the ones after the current date.
Will anyone please help me?
 
This isn't going to work because the #CreateODBCDate(now())# will return something like 2000-05-09 10:00:00.000 (yyyy-mm-dd hh:mm:ss.sss) I assume that your field StartDate is not of SQL type DATETIME if it was your above query would work. I suggest you either convert the StartDate to DATETIME or try this piece of code.

Code:
select * from Date 
where CONVERT(DATETIME,StartDate,112) >= #CreateODBCDate(now())#

 
With your help I got it to work Ded, Thanx!
 
Thanks Ded,

I had the same problem. My date was in the same format as "now" so this simple code worked for me.

Also, I was more concerned with the EndDate than the start date. For example if the event started a long time ago, but was not over yet I still wanted to show the event.

select * from Date
where EndDate >=
#CreateODBCDate(now())#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top