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 |
|
learntsql
524 Posts |
Posted - 2010-11-15 : 05:31:27
|
| How to convert follwing output back to date/datetime value.select CONVERT(varchar,GETDATE(),112)TIA. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-15 : 05:43:57
|
| select CONVERT(Datetime,CONVERT(varchar,GETDATE(),112))But another method isselect dateadd(day,datediff(day,0,getdate()),0)MadhivananFailing to plan is Planning to fail |
 |
|
|
learntsql
524 Posts |
Posted - 2010-11-15 : 05:51:16
|
| Sorry Madhi,I didnt post properly..I stored CONVERT(varchar,DateColumn,112) under bigint column,In one of my query i have to convert this bigint back to datetime.Is this possible? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-15 : 05:58:39
|
quote: Originally posted by learntsql Sorry Madhi,I didnt post properly..I stored CONVERT(varchar,DateColumn,112) under bigint column,In one of my query i have to convert this bigint back to datetime.Is this possible?
You should always use proper DATETIME datatype to store datesselect convert(datetime,cast(col as char(8))) from your_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
learntsql
524 Posts |
Posted - 2010-11-15 : 06:03:31
|
| ThanX Madhi It worked great. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-15 : 06:12:39
|
quote: Originally posted by learntsql ThanX Madhi It worked great.
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|