@@ -311,16 +311,16 @@ QVariant::Type QgsMssqlProvider::DecodeSqlType( QString sqlTypeName )
311
311
{
312
312
type = QVariant::ByteArray;
313
313
}
314
- else if ( sqlTypeName.startsWith ( " date" , Qt::CaseInsensitive ) )
315
- {
316
- type = QVariant::Date;
317
- }
318
314
else if ( sqlTypeName.startsWith ( " datetime" , Qt::CaseInsensitive ) ||
319
315
sqlTypeName.startsWith ( " smalldatetime" , Qt::CaseInsensitive ) ||
320
316
sqlTypeName.startsWith ( " datetime2" , Qt::CaseInsensitive ) )
321
317
{
322
318
type = QVariant::DateTime;
323
319
}
320
+ else if ( sqlTypeName.startsWith ( " date" , Qt::CaseInsensitive ) )
321
+ {
322
+ type = QVariant::Date;
323
+ }
324
324
else if ( sqlTypeName.startsWith ( " time" , Qt::CaseInsensitive ) ||
325
325
sqlTypeName.startsWith ( " timestamp" , Qt::CaseInsensitive ) )
326
326
{
@@ -879,6 +879,21 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
879
879
// binding a TEXT value
880
880
query.addBindValue ( attrs[i].toString () );
881
881
}
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
+ }
882
897
else
883
898
{
884
899
query.addBindValue ( attrs[i] );
@@ -1119,6 +1134,21 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap &att
1119
1134
// binding a TEXT value
1120
1135
query.addBindValue ( it2->toString () );
1121
1136
}
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
+ }
1122
1152
else
1123
1153
{
1124
1154
query.addBindValue ( *it2 );
0 commit comments