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 |
|
AlexP
Starting Member
34 Posts |
Posted - 2005-08-25 : 10:39:31
|
| I need to get the day of the month like this 05 from this value.01\05\1978I get the error: Syntax error converting datetime from character string.I am using this code:CAST(day('01\05\1978') as varchar) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-25 : 10:43:51
|
| If your table has datetime column then you can simply useSelect day(DatetimeColumn) from yourTableOtherwise you have to convert it to datetimeSelect day(CAST('01/05/1978' as datetime))MadhivananFailing to plan is Planning to fail |
 |
|
|
nosepicker
Constraint Violating Yak Guru
366 Posts |
Posted - 2005-08-25 : 12:13:03
|
| You cannot use backslashes in a date format. Need to convert them to forward slashes:SELECT CAST(day(REPLACE('01\05\1978', '\', '/')) as varchar) |
 |
|
|
|
|
|