hi.

how can i convert string format to datetime:

the string is formatted like : December 01, 2010 (which is another table) tblTransactions
and the datetime column format is : 2010-12-01 (another table) tblBilling

how can i search my string format to my table which matches the column (datetime field).

Thank You.

Recommended Answers

SELECT somefield FROM tblTransactions WHERE somedatetimecolumn = STR_TO_DATE('$stringdate','%M %d, %Y');

Assuming you're using PHP - $stringdate and MySQL. You don't give much info, do you?

Jump to Post

I assume your database is mysql

select str_to_date(string_date_col, '%M %d, %Y') from tblTransaction

Str_to_date function will change string to date type

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_str-to-date

Jump to Post

All 4 Replies

Member Avatar
SELECT somefield FROM tblTransactions WHERE somedatetimecolumn = STR_TO_DATE('$stringdate','%M %d, %Y');

Assuming you're using PHP - $stringdate and MySQL. You don't give much info, do you?

hi..sorry..i was not able to say..im using SQL Server 2005.
Thank You.

hey i found the solution..

SELECT convert(datetime, @somestringcolumn) from tblTransactions

Thanks..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.