|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dates from multiple fieldsI have fields that are listed as nvarchar in a table. Field1 contains
the month, Field2 contains the day, Field3 contains the year. I need to pick stuff off this table with a "date" >= 12/10/2004. How do you construct the "date" from the 3 fields above? I've tried cast & converts on it, but have not hit the correct combination. Any help appreciated. BC concatenate and add '/' between the fields and convert the whole thing to a
datetime http://sqlservercode.blogspot.com/ Show quote "Blasting Cap" wrote: > I have fields that are listed as nvarchar in a table. Field1 contains > the month, Field2 contains the day, Field3 contains the year. > > I need to pick stuff off this table with a "date" >= 12/10/2004. > > How do you construct the "date" from the 3 fields above? > > I've tried cast & converts on it, but have not hit the correct combination. > > Any help appreciated. > > BC > > Blasting,
Try: SELECT <COLUMNS> FROM <TABLE> WHERE CAST(CAST(FIELD3+FIELD2+FIELD1 AS CHAR(8)) AS DATETIME) < ETDATE() -- OR OTHER DATE HTH Jerry Show quote "Blasting Cap" <goo***@christian.net> wrote in message news:uWQkDUl1FHA.1028@TK2MSFTNGP12.phx.gbl... >I have fields that are listed as nvarchar in a table. Field1 contains the >month, Field2 contains the day, Field3 contains the year. > > I need to pick stuff off this table with a "date" >= 12/10/2004. > > How do you construct the "date" from the 3 fields above? > > I've tried cast & converts on it, but have not hit the correct > combination. > > Any help appreciated. > > BC >
Other interesting topics
|
|||||||||||||||||||||||