VBdotnet2005
asked on
Check Month year if exists
I have a column called Recevieddate (datetime). I have a string '2/1/2015'. I want to check if month and year exists in Recevieddate when I pass @mydate. Date does not matter.
Sample date
2015-02-01 00:00:00.000
2015-02-06 00:00:00.000
2015-03-05 00:00:00.000
2015-04-15 00:00:00.000
declare @mydate varchar(12)
set@mydate = '2/1/2015'
declare @tf char(1)
if exists(select *from table1 where receiveddate = @mydate ???)
begin
set @tf = 'True'
end
else
begin
set @tf = 'false
end
Sample
2/1/2015 should return true because month year exists in Recevieddate
2/15/2015 should return true
Sample date
2015-02-01 00:00:00.000
2015-02-06 00:00:00.000
2015-03-05 00:00:00.000
2015-04-15 00:00:00.000
declare @mydate varchar(12)
set@mydate = '2/1/2015'
declare @tf char(1)
if exists(select *from table1 where receiveddate = @mydate ???)
begin
set @tf = 'True'
end
else
begin
set @tf = 'false
end
Sample
2/1/2015 should return true because month year exists in Recevieddate
2/15/2015 should return true
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
vbdotnet2005, do you still need help with this question?