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.
| Author |
Topic |
|
Sunny155
Starting Member
15 Posts |
Posted - 2009-04-04 : 08:18:30
|
| Hi, Can i input the date in datetime or smalldatetime field in mm/yyyy (06/2007) format? is it possible? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-04 : 08:30:24
|
| declare @date varchar(7)set @date='06/2007'select cast(right(@date,4)+left(@date,2)+'01' as datetime)MadhivananFailing to plan is Planning to fail |
 |
|
|
Sunny155
Starting Member
15 Posts |
Posted - 2009-04-04 : 08:34:32
|
| Thanks! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-04-04 : 09:28:31
|
quote: Originally posted by Sunny155 Thanks!
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
zeus2026
Starting Member
11 Posts |
Posted - 2009-04-06 : 01:32:54
|
| sir I have a problem related in this thread, I also want to convert the datehired (1/31/2009) into (1/2009), but how? sorry for this newbie question, im just only a beginner in stdying sql =( tnx..z3us |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-04-06 : 01:40:52
|
| use month() and year() functionSelect * from..... where month(1/31/2009)<'...' and year(1/31/2009)<'...'RegardsSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceled |
 |
|
|
zeus2026
Starting Member
11 Posts |
Posted - 2009-04-06 : 02:07:39
|
| sir how about this... how can i use date diff and dateadd in this code?SELECT EmployeeName, RIGHT(CONVERT(varchar, DateHired, 105), 7) AS DateFROM viewEmployeeWHERE (DateHired >= '11/01/08') AND (Separated = 0) AND (DeptID < 39)ORDER BY DateHired--------------- how can I view all of the employee that have been reach in 5 months cotract since the day that they hired...sorry for this newbie question.....tnx to all master....z3us |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-06-02 : 04:41:45
|
| SELECT EmployeeName, RIGHT(CONVERT(varchar, DateHired, 105), 7) AS DateFROM viewEmployeeWHERE (DateHired <= dateadd(month,-5,getdate()) AND (Separated = 0) AND (DeptID < 39)ORDER BY DateHiredMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|