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 |
|
bhanu2217
Starting Member
35 Posts |
Posted - 2010-05-22 : 02:29:37
|
| All my dates/times are stored in UTC format in database.Is it possible to convert them into Indian standard time in query itself?(while i am retrieving the records)www.JamboreeBliss.com |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-05-22 : 03:18:12
|
| you can use dateadd function and add the minutes.. |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-05-22 : 03:18:44
|
The only way would be to use the DATEADD function. You could create your own user defined function and do something like this:CREATE FUNCTION dbo.UTC2Indian ( @UTCTime datetime)RETURNS datetimeASBEGIN SET @UTCTime = DATEADD(mm, 330, @UTCTime) RETURN @UTCTimeEND And then in your query just do like this SELECT myUTCTimeColumn, dbo.UTC2Indian(myUTCTimeColumn) FROM table- LumbagoMy blog (yes, I have a blog now!) -> www.thefirstsql.com |
 |
|
|
bhanu2217
Starting Member
35 Posts |
Posted - 2010-05-22 : 03:43:08
|
| Thank You.www.JamboreeBliss.com |
 |
|
|
bhanu2217
Starting Member
35 Posts |
Posted - 2010-05-22 : 03:49:32
|
| Small problem here my Year become 2037 instead of 2010 if u use the above procedure and querywww.JamboreeBliss.com |
 |
|
|
bhanu2217
Starting Member
35 Posts |
Posted - 2010-05-22 : 03:52:29
|
| 6 months are added to the month also.www.JamboreeBliss.com |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-05-22 : 04:04:16
|
| use SET @UTCTime = DATEADD(mi, 330, @UTCTime) |
 |
|
|
bhanu2217
Starting Member
35 Posts |
Posted - 2010-05-22 : 06:25:20
|
| Thank You.www.JamboreeBliss.com |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-05-22 : 06:27:18
|
Glad to help |
 |
|
|
|
|
|