Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
query as follows;
 
Sql = "select s.Name,s.DOB,s.Mobileno,s.Weddingday from BirthDayWish s where s.Active <> 'D'";
 Sql = Sql + " and year(DOB) <> '1900'";
Sql = Sql + "and month(DOB) = month(' " + Convert.ToDateTime(CurDate) + "') and day(DOB) = day (' " + Convert.ToDateTime(CurDate) + "') ";
 Sql = Sql + " or year(Weddingday)  <>'1900'";                   
Sql = Sql + " or month(Weddingday) = month('" + Convert.ToDateTime(CurDate) + "')  or day(Weddingday) = day ('" + Convert.ToDateTime(CurDate) + "')";

Database type as follows;
 
  DOB                  Datetime    
 Weddingdate           Datetime
 
i am sending sms for Birthday And Wedding.
 
i have following condition
 
when year in database DOB and Wedding date not equal(<>) to 1900 year message not be send.
 
when year in database DOB 4/2/1900 message not be send
When year in database Wedding 7/2/1900 message not be send.
 
when year in database DOB 28/12/1985 and Wedding date 6/7/2010 in that case birthday wish and Wedding date message both to be send at a time.
 
i send the query,form that query how to write my condition using else.using else send query for my above query.
Posted 27-Dec-12 21:34pm
Edited 27-Dec-12 21:52pm
v2
Comments
Sandeep Mewara at 28-Dec-12 3:52am
   
i send the query,form that query how to write my condition using else.using else send query for my above query.
Your question is not clear. Where are you stuck and whats troubling you?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi

Plz check it,
SELECT 'Birthday' as Event , dob from dbo.BirthDayWish
WHERE YEAR (DOB) <> 1900
AND DAY(GETDATE()) = DAY (DOB)
AND MONTH(GETDATE()) = MONTH (DOB)
UNION
SELECT 'Wedding' as Event , Weddingday from dbo.BirthDayWish
WHERE YEAR (Weddingday) <> 1900
AND DAY(GETDATE()) = DAY (Weddingday)
AND MONTH(GETDATE()) = MONTH (Weddingday)
If I missed any condition plz let me know ....
 
Happy New Year....wish you good luck Smile | :)
Regards
Vijay
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

select s.Name,s.DOB,s.Mobileno,s.Weddingday from BirthDayWish s where 
Year(s.Dob)<>1900 And Convert(varchar,s.DOB,106)<>'28 Dec 1985' and Convert(varchar,s.Weddingdate,106)<>'06 Jul 2010'
 
Enjoy Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 540
1 Sergey Alexandrovich Kryukov 407
2 Yogesh Kumar Tyagi 384
3 Prakriti Goyal 280
4 Maciej Los 205
0 OriginalGriff 6,632
1 Sergey Alexandrovich Kryukov 5,429
2 Maciej Los 3,474
3 Peter Leow 3,309
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100