Date Format On Sql Server (1 Viewer)

Allan.Day

Registered User.
Local time
Today, 13:06
Joined
May 18, 2013
Messages
25
Dear All

I have two table
1. dbo.period (OpeningDate, ClosingDate)
2. dbo.data (blah blah, doc_date)

I want to create a view as follows

Select doc_date from dbo.data
where doc_date> 'select OpeningDate from dbo.period'

both doc_date and opening date have the same format

but the error will still appear as follows:
"Conversion failed when converting date and / or time from character string."

thank you for helping

Allan.Day
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 16:06
Joined
Jan 20, 2009
Messages
12,863
Select doc_date from dbo.data
where doc_date IN (select OpeningDate from dbo.period)
 

Allan.Day

Registered User.
Local time
Today, 13:06
Joined
May 18, 2013
Messages
25
Select doc_date from dbo.data
where doc_date IN (select OpeningDate from dbo.period)

actually the need is between openingdate and closingdate

Doesnt Work :

WHERE doc_date Between IN (SELECT OpeningDate from dbo.PeriodTbl) and IN (SELECT ClosingDate from dbo.PeriodTbl)
 

Users who are viewing this thread

Top Bottom