?
Solved

Clueless about the right syntax. (GETDATE)

Posted on 2011-03-17
2
Medium Priority
?
252 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

770 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