Solved

Clueless about the right syntax. (GETDATE)

Posted on 2011-03-17
2
250 Views
Last Modified: 2012-05-11
Question: I would like to use GETDATE() in combination with IF THEN.

SELECT datepart(mm,getdate()) WHEN 1 print ''yada yada yada" ELSE print "yoda yoda yoda"

Since I'm a noob with SQL I can't seem to get the notation right.
I have searched myself silly on the web for the answer but with no luck.
Could someone tell me what the correct notation should be?

Thanks in advance!

Best regards,
Clyde.
0
Comment
Question by:Clyde_Radcliffe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35155955
check out this:

SELECT CASE datepart(mm,getdate()) WHEN 1 THEN 'yada yada yada' ELSE 'yoda yoda yoda' END

Open in new window


resp:

declare @res varchar(100) 
SELECT CASE datepart(mm,getdate()) WHEN 1 THEN 'yada yada yada' ELSE 'yoda yoda yoda' END
print @res

Open in new window

0
 

Author Comment

by:Clyde_Radcliffe
ID: 35155990
@angelllll: Excellent! Thanks for the help!!!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need return values from a stored procedure 8 43
SQL Server 2008 R2 service pack updates 5 46
Not listening to where 1 22
Need multiple Group By's 8 28
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question