Click to See Complete Forum and Search --> : Timestamp and String conversion ?


wxuf
June 6th, 2005, 10:15 PM
hi:

I will open an edit box for user to input the time then I will save this time to database. In database, the Attribute type is "(date)Timestamp". but I get a string from the edit box, how can I convert it to "Timestamp" with a speicified format ( such as "day/mon/year hour:minute:second AM ").

I use SQL server 2000.

wxuf

cjard
June 7th, 2005, 04:38 AM
this isnt a java question; whatever programming language you use, you will write the SQL query with the CONVERT function..

you pass in your date as a string, and convert it to a date on the server:

SELECT * FROM tblEmployees WHERE dateOfBirth = CONVERT( ..... )


the ..... should contain: your string representing their birthday, and the datetime type

see here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp

wxuf
June 7th, 2005, 09:57 PM
Thank you very much !