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 |
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2009-11-17 : 06:15:52
|
| Don't ask why But I got this tabel with seperate (int) colums for:- year- month- day- hour- minute- secondSo how can I make a get / add / update sp which will enter or return the data as a normal datetime column, but still write it to the tabel as integers.Should I do something like:convert(Datetime, [Year] & '-' & [Month] & '-' & [Day] & ' ' & [Hour] & ':' & [Minute] & ':' & [Seconds], 120)It says: Conversion failed when converting the varchar value ':' to data type int. |
|
|
sanoj_av
Posting Yak Master
118 Posts |
Posted - 2009-11-17 : 06:48:48
|
| Select convert(Datetime, str([Year]) + '-' + str([Month]) + '-' + str([Day]) + ' ' + str([Hour]) + ':' + str([Minute]) + ':' + str([Seconds]), 120)From <Table_name> |
 |
|
|
trouble2
Constraint Violating Yak Guru
267 Posts |
Posted - 2009-11-17 : 07:24:12
|
| Ok, thanks, and how about inserts...The secret to creativity is knowing how to hide your sources. (Einstein) |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-11-17 : 08:55:36
|
| DatePart(year, datevalue)DatePart(month, datevalue)DatePart(day, datevalue)DatePart(hour, datevalue)DatePart(minute, datevalue)DatePart(second, datevalue) |
 |
|
|
|
|
|
|
|