November 26, 2004 at 3:41 am
Hi, I have a table of employees that contains a start_date from which I am creating a view for ODBC reporting.
I am creating a date called anniversary in the view using Dateadd(month,6,start_date) and that works fine.
My problem is that I would like to set the anniversary date to a set date where the start date is before 1st May 2004.
Guess there must be a way but I'm struggling. Anyone out there got any ideas? Thanks in advance.
November 26, 2004 at 3:50 am
Hi Helen,
Does a straight WHERE clause not fulfill your requirements.
SELECT PK, StartDate FROM DateTest
WHERE StartDate > CAST('01/05/2004' as datetime)
Have fun
Steve
We need men who can dream of things that never were.
November 26, 2004 at 4:21 am
Helen,
can you explain this with an example?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 26, 2004 at 4:50 am
CASE WHEN start_date < '2004-05-01'
THEN '2004-05-01'
ELSE Dateadd(month,6,start_date)
END AS [anniversary]
Far away is close at hand in the images of elsewhere.
Anon.
November 26, 2004 at 7:03 am
Hi Gents,
And its not even a Dynamic SQL question.......
Steve
We need men who can dream of things that never were.
November 26, 2004 at 7:16 am
Okay, some Friday funnies:
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 26, 2004 at 7:30 am
Nice one Frank,
I will use that one on my kids.......
Have a good weekend.
Best Regards
Steve
We need men who can dream of things that never were.
November 26, 2004 at 7:41 am
You, too.
Here's one more: http://www.baetzler.de/humor/null.html
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 26, 2004 at 8:26 am
David, Thanks for your help it works a dream.
Regarding the funnies, I will take them in the spirit they were meant (I hope)
Were you never beginners????
November 26, 2004 at 8:43 am
One thing to watch out for is the default language under which your server is configured.
If it is US_English then CAST('01/05/2004' AS SMALLDATETIME) will give 5th January 2004.
To get around this use SET DATEFORMAT MDY or SET DATEFORMAT DMY before your cast statement.
The old fashioned way was to submit your date to a stored procedure as a string of known format and then use CONVERT(SMALLDATETIME,@param,103).
November 29, 2004 at 1:21 am
Regarding the funnies, I will take them in the spirit they were meant (I hope)
Gee, no. The funnies had nothing to do with your question!!!
Please, don't get this wrong. If you felt offended in any way, I apologize for this.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 29, 2004 at 2:15 am
Regarding the funnies, I will take them in the spirit they were meant (I hope) |
Helen,
The humerous anecdotes are always intended to be innocent, innocuous and never personal (with a few exceptions) whether they refer to the subject in question or not. I have never known Frank to insult anyone ( nice chap ).
Were you never beginners???? |
Yep and still am. My knowledge is only surpassed by my stupidity
Far away is close at hand in the images of elsewhere.
Anon.
November 29, 2004 at 2:21 am
Helen,
There was definatley no intention to insult or offend. It was just Friday and wind down.....
Frank, David - I think it must be me
Have fun
Steve
We need men who can dream of things that never were.
November 29, 2004 at 2:29 am
Wrong!
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 29, 2004 at 3:07 am
Hey, I should have rather posted this instead:
http://dsc.discovery.com/news/afp/20040823/psychopath.html
And identify the common "management enemy"
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply