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 |
|
bill_
Starting Member
38 Posts |
Posted - 2010-02-16 : 18:47:30
|
| Am trying convert(char(8),datecol,112) in a query to try to go from datecols datetime type to yyyymmdd.Getting error message that datecol is not a the datasource.It is in a vb.net program.Without the convert, the query runs but returns a date and time and just want the date.Running in the sql server management studio, it works too.How do I get the query to return yyymmdd or mm/dd/yy ?Thanks. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-16 : 23:47:14
|
quote: Originally posted by bill_ Am trying convert(char(8),datecol,112) in a query to try to go from datecols datetime type to yyyymmdd.Getting error message that datecol is not a the datasource.It is in a vb.net program.Without the convert, the query runs but returns a date and time and just want the date.Running in the sql server management studio, it works too.How do I get the query to return yyymmdd or mm/dd/yy ?Thanks.
you can use the below to get only date partDATEADD(dd,DATEDIFF(dd,0,yourdatefield),0)then you can use formatting functions available at your front end to get the date in format you want.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
onlyforme
Starting Member
25 Posts |
Posted - 2010-02-17 : 01:26:56
|
| check this linkhttp://www.sqlusa.com/bestpractices/datetimeconversion/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-17 : 01:27:37
|
quote: Originally posted by bill_ Am trying convert(char(8),datecol,112) in a query to try to go from datecols datetime type to yyyymmdd.Getting error message that datecol is not a the datasource.It is in a vb.net program.Without the convert, the query runs but returns a date and time and just want the date.Running in the sql server management studio, it works too.How do I get the query to return yyymmdd or mm/dd/yy ?Thanks.
Make use of Format function in VB.NETMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|