Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2008, 03:30 AM
Authorized User
 
Join Date: Oct 2007
Posts: 46
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to debbiecoates
Default Convert date not working

i am trying to format a date returns to dd/mm/yy

the sql statement i have is

SELECT ProjectPanelID,
    Case DecisionBy When 'Board' THEN DateOfBoard
            When 'Panel' THEN DateOfPanel
            END As DecisionDate
FROM PROJECTPANEL

Which works fine but returns the date AND time, and I just want the date in a particular format.

So I tried this

SELECT ProjectPanelID,
CONVERT(VARCHAR(10), Case DecisionBy
            When 'Board' THEN DateOfBoard
            When 'Panel' THEN DateOfPanel
            END As DecisionDate, 101) AS [MM/DD/YYYY]
FROM PROJECTPANEL

but now I keeping getting Incorrect syntax near the keyword 'As'.
can anyone help?

many Thanks


 
Old August 5th, 2008, 03:34 AM
Authorized User
 
Join Date: Oct 2007
Posts: 46
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via MSN to debbiecoates
Default

I've managed to work it out now. here is the solution, should anyone else need it

SELECT ProjectPanelID,
CONVERT(VARCHAR, Case DecisionBy
            When 'Board' THEN DateOfBoard
            When 'Panel' THEN DateOfPanel
            END, 101) as DecisionDate
FROM PROJECTPANEL






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert string to date tgopal Javascript 2 March 18th, 2008 03:33 AM
convert date NARJES VB Databases Basics 1 May 22nd, 2007 01:02 PM
date convert keyvanjan Classic ASP Databases 2 May 15th, 2005 01:02 AM
Date convert Problem ppenn Access VBA 3 September 13th, 2004 02:15 PM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.