Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

MSSQL The conversion of a varchar data type to a datetime data type resulted in an out-of-range value


Go to End


2 Posts   4578 Views

Avatar
lanks

Community Member, 61 Posts

13 January 2012 at 7:34am

I have been running a website on MS SQL Server/Windows Server 2008 without any issues. Now all of a sudden it can't run any queries where it is updating date values.... I have tried executing these queries manually through the sql server management studio and they run fine.

I tried to do a fresh install of Silverstripe and this is what I got when running the install:

[User Error] Couldn't run query (22007, 242, [Microsoft][SQL Server Native Client 10.0][SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.01000, 3621, [Microsoft][SQL Server Native Client 10.0][SQL Server]The statement has been terminated.): UPDATE "SiteConfig" SET "ClassName" = 'SiteConfig', "Title" = 'Your Site Name', "Tagline" = 'your tagline here', "LastEdited" = '2012-01-13 07:29:48', "Created" = '2012-01-13 07:29:48' where "ID" = 1: [Microsoft][SQL Server Native Client 10.0][SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.; [Microsoft][SQL Server Native Client 10.0][SQL Server]The statement has been terminated.
POST /install.php

Line 620 in C:\inetpub\wwwroot\dlproperty\sapphire\core\model\Database.php
Source

611 	/**
612 	 * Error handler for database errors.
613 	 * All database errors will call this function to report the error.  It isn't a static function;
614 	 * it will be called on the object itself and as such can be overridden in a subclass.
615 	 * @todo hook this into a more well-structured error handling system.
616 	 * @param string $msg The error message.
617 	 * @param int $errorLevel The level of the error to throw.
618 	 */
619 	function databaseError($msg, $errorLevel = E_USER_ERROR) {
620 		user_error($msg, $errorLevel);
621 	}
622 	
623 	/**
624 	 * Enable supression of database messages.
625 	 */
626 	function quiet() {

Trace

    Couldn't run query (22007, 242, [Microsoft][SQL Server Native Client 10.0][SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.01000, 3621, [Microsoft][SQL Server Native Client 10.0][SQL Server]The statement has been terminated.): UPDATE "SiteConfig" SET "ClassName" = 'SiteConfig', "Title" = 'Your Site Name', "Tagline" = 'your tagline here', "LastEdited" = '2012-01-13 07:29:48', "Created" = '2012-01-13 07:29:48' where "ID" = 1: [Microsoft][SQL Server Native Client 10.0][SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.; [Microsoft][SQL Server Native Client 10.0][SQL Server]The statement has been terminated.
    Line 620 of Database.php
    SS_Database->databaseError(Couldn't run query (22007, 242, [Microsoft][SQL Server Native Client 10.0][SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.01000, 3621, [Microsoft][SQL Server Native Client 10.0][SQL Server]The statement has been terminated.): UPDATE "SiteConfig" SET "ClassName" = 'SiteConfig', "Title" = 'Your Site Name', "Tagline" = 'your tagline here', "LastEdited" = '2012-01-13 07:29:48', "Created" = '2012-01-13 07:29:48' where "ID" = 1: [Microsoft][SQL Server Native Client 10.0][SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.; [Microsoft][SQL Server Native Client 10.0][SQL Server]The statement has been terminated.,256)
    Line 209 of MSSQLDatabase.php
    MSSQLDatabase->databaseError(Couldn't run query (22007, 242, [Microsoft][SQL Server Native Client 10.0][SQL Server]The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.01000, 3621, [Microsoft][SQL Server Native Client 10.0][SQL Server]The statement has been terminated.): UPDATE "SiteConfig" SET "ClassName" = 'SiteConfig', "Title" = 'Your Site Name', "Tagline" = 'your tagline here', "LastEdited" = '2012-01-13 07:29:48', "Created" = '2012-01-13 07:29:48' where "ID" = 1,256)
    Line 310 of MSSQLDatabase.php
    MSSQLDatabase->query(UPDATE "SiteConfig" SET "ClassName" = 'SiteConfig', "Title" = 'Your Site Name', "Tagline" = 'your tagline here', "LastEdited" = '2012-01-13 07:29:48', "Created" = '2012-01-13 07:29:48' where "ID" = 1)
    Line 568 of Database.php
    SS_Database->manipulate(Array)
    Line 174 of DB.php
    DB::manipulate(Array)
    Line 1048 of DataObject.php
    DataObject->write()
    Line 206 of SiteConfig.php
    SiteConfig::make_site_config()
    Line 173 of SiteConfig.php
    SiteConfig->requireDefaultRecords()
    Line 235 of DatabaseAdmin.php
    DatabaseAdmin->doBuild(1)
    Line 1093 of install.php
    Installer->install(Array)
    Line 190 of install.php

Any help is much appreciated.

Liam

Avatar
ronaan

Community Member, 9 Posts

13 April 2012 at 9:32pm

I get the same error on a running installation that worked fine for oh, something like 10 days.
No idea what I did wrong, seems I changed the date format and added a user or two.
Now when I try to log into the admin panel I get that error.

Any ideas how to fix this without destroying 10 days worth of content?

Windows Server 2008 R2
SQLExpress