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

Matching a date, which may be zero

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have an SP which has a date as a variable.

I want to test for either 0 or CCYYMMDD (ie 20011105).

The date in the table which is to be matched is defined as
numeric, & can either be zero, or CCYYMMDDHHMMSS.

I have written
substring(convert(char(16),<tabledate>),1,8) = @date
but this doesnt' work for zero.

I have also tried convert(numeric(@date)) but this doesn't work either.

Can anyone give me the code please ?


PS The DB is SYBASE.

Many thanks
 
Assuming that
Code:
WHERE
substring(convert(char(16),<tabledate>),1,8) = @date
works when @date has a non-zero value why not just add
the condition that <tabledate> is zero

Code:
WHERE
substring(convert(char(16),<tabledate>),1,8) = @date
OR <tabledate> = 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top