@@ -311,16 +311,16 @@ QVariant::Type QgsMssqlProvider::DecodeSqlType( QString sqlTypeName )
311311 {
312312 type = QVariant::ByteArray;
313313 }
314- else if ( sqlTypeName.startsWith ( " date" , Qt::CaseInsensitive ) )
315- {
316- type = QVariant::Date;
317- }
318314 else if ( sqlTypeName.startsWith ( " datetime" , Qt::CaseInsensitive ) ||
319315 sqlTypeName.startsWith ( " smalldatetime" , Qt::CaseInsensitive ) ||
320316 sqlTypeName.startsWith ( " datetime2" , Qt::CaseInsensitive ) )
321317 {
322318 type = QVariant::DateTime;
323319 }
320+ else if ( sqlTypeName.startsWith ( " date" , Qt::CaseInsensitive ) )
321+ {
322+ type = QVariant::Date;
323+ }
324324 else if ( sqlTypeName.startsWith ( " time" , Qt::CaseInsensitive ) ||
325325 sqlTypeName.startsWith ( " timestamp" , Qt::CaseInsensitive ) )
326326 {
@@ -879,6 +879,21 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
879879 // binding a TEXT value
880880 query.addBindValue ( attrs[i].toString () );
881881 }
882+ else if ( type == QVariant::Time )
883+ {
884+ // binding a TIME value
885+ query.addBindValue ( attrs[i].toTime ().toString ( Qt::ISODate ) );
886+ }
887+ else if ( type == QVariant::Date )
888+ {
889+ // binding a DATE value
890+ query.addBindValue ( attrs[i].toDate ().toString ( Qt::ISODate ) );
891+ }
892+ else if ( type == QVariant::DateTime )
893+ {
894+ // binding a DATETIME value
895+ query.addBindValue ( attrs[i].toDateTime ().toString ( Qt::ISODate ) );
896+ }
882897 else
883898 {
884899 query.addBindValue ( attrs[i] );
@@ -1119,6 +1134,21 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap &att
11191134 // binding a TEXT value
11201135 query.addBindValue ( it2->toString () );
11211136 }
1137+ else if ( type == QVariant::DateTime )
1138+ {
1139+ // binding a DATETIME value
1140+ query.addBindValue ( it2->toDateTime ().toString ( Qt::ISODate ) );
1141+ }
1142+ else if ( type == QVariant::Date )
1143+ {
1144+ // binding a DATE value
1145+ query.addBindValue ( it2->toDate ().toString ( Qt::ISODate ) );
1146+ }
1147+ else if ( type == QVariant::Time )
1148+ {
1149+ // binding a TIME value
1150+ query.addBindValue ( it2->toTime ().toString ( Qt::ISODate ) );
1151+ }
11221152 else
11231153 {
11241154 query.addBindValue ( *it2 );
0 commit comments