求一条简单的Sql语句

来源:百度知道 编辑:UC知道 时间:2024/07/01 16:26:24
CString strSQL;
strSQL.Format("insert into test( name, age, birthday, maxage ) values ('hello',100,#%s#,200)",COleDateTime::GetCurrentTime());
我要将当前的时间放入数据库,请问该怎么写SQL语句啊

COleDateTime::GetCurrentTime()返回的是COleDateTime类型。需要格式化:

CString csTime;
COleDateTime odTime = COleDateTime::GetCurrentTime();
csTime.Format( "%d/%d/%d", odTime.GetYear(),odTime.GetMonth(), odTime.GetDay() );

CString strSQL;
strSQL.Format("insert into test( name, age, birthday, maxage ) values ('hello',100,#%s#,200)",csTime );

SQL语句,时间类型转换,CONVERT