Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need help here

Author  Topic 

zeus2026
Starting Member

11 Posts

Posted - 2009-04-06 : 01:06:12
SELECT EmployeeName, CONVERT(varchar, DateHired, 101) AS Date
FROM viewEmployee
WHERE (DateHired >= '5/01/08') AND (Separated = 0) AND (DeptID < 39)
ORDER BY DateHired

in this code i want to view all the employee where 5 months contract has been done in the months of April, 2009 but I should view the table with no specific date.. like this

EmployeeName DateHired
Marlon 11-2008

please kindly help me huhuh. Thanks

z3us

matty
Posting Yak Master

161 Posts

Posted - 2009-04-06 : 01:31:26
SELECT EmployeeName, RIGHT(CONVERT(varchar, DateHired, 105),7) AS Date
FROM viewEmployee
WHERE (DateHired >= '5/01/08') AND (Separated = 0) AND (DeptID < 39)
ORDER BY DateHired
Go to Top of Page

zeus2026
Starting Member

11 Posts

Posted - 2009-04-06 : 01:35:33
thnx sir..

z3us
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-04-06 : 01:37:31
go through these links for format of dates
http://www.sql-server-helper.com/tips/date-formats.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80563
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-06 : 05:18:14

If you want to show formatted dates in front end application, do formation there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

nishita_s
Yak Posting Veteran

61 Posts

Posted - 2009-04-06 : 05:41:17
SELECT EmployeeName, CAST(MONTH(DateHired)AS VARCHAR(2)) + '-' + CAST(YEAR(DateHired)AS VARCHAR(4)) AS Date
FROM viewEmployee
WHERE (DateHired >= '5/01/08') AND (Separated = 0) AND (DeptID < 39)
ORDER BY DateHired
Go to Top of Page
   

- Advertisement -