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 |
|
sqldba2k6
Posting Yak Master
176 Posts |
Posted - 2006-12-13 : 12:58:29
|
| Please help me in date conversion to MMDDYYY..select convert(varchar,'2006254',101)i want the output below04/25/2006 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-12-13 : 13:12:38
|
| What format will the data in the database be in? YYYYDDM, YYYYDDMM? It would make it a lot easier if it were 20062504.And BTW, this should usually be done in the presentation layer rather than in T-SQL. Tara Kizer |
 |
|
|
sqldba2k6
Posting Yak Master
176 Posts |
Posted - 2006-12-13 : 13:30:22
|
| I want to validate the julian dates..instead of converting the date.Since some the date values are being stored correctly.. |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-12-13 : 14:32:11
|
quote: Originally posted by sqldba2k6 I want to validate the julian dates..instead of converting the date.Since some the date values are being stored correctly..
By Julian date, do you mean the Ordinal day of year. In other words, 2006254 would mean day 254 of year 2006?If that is the case, this code should do it.select Date = dateadd(day,convert(int,substring(a.DT,5,3)-1), dateadd(year,convert(int,substring(a.DT,1,4))-1900,0))from (Select DT = '2006254' ) a Results:Date ------------------------------------------------------ 2006-09-11 00:00:00.000(1 row(s) affected) CODO ERGO SUM |
 |
|
|
|
|
|
|
|