Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6948651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:51:03+00:00 2026-05-27T13:51:03+00:00

I am building some test scenarios for my application. In order to do this,

  • 0

I am building some test scenarios for my application. In order to do this, I have some code that is generating some SQL to help me test properly. A sample of the SQL that is generated is shown here:

INSERT INTO MyTable
(
 [ID],
 [Name],
 [CheckInDate],
 [CheckOutDate]
)
VALUES
(
  1,
  'A title',
  'Sat, 17 Dec 2011 14:33:12 GMT',
  'Sat, 17 Dec 2011 15:13:12 GMT'
)

When I attempt to execute this SQL, I receive the following:
Conversion failed when converting date and/or time from character string.

How can i format the date/time strings so that SQL Server 2008 will accept them? I really need my C# code to generate the SQL (including the date/time items) to create my tests properly.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:51:04+00:00Added an answer on May 27, 2026 at 1:51 pm

    The way to solve this is to use the ISO-8601 date format that is supported by SQL Server – this format works always – regardless of your SQL Server language and dateformat settings.

    The ISO-8601 format is supported by SQL Server comes in two flavors:

    • YYYYMMDD for just dates (no time portion) – note here: no dashes!, that’s very important! YYYY-MM-DD is NOT independent of the dateformat settings in your SQL Server and will NOT work in all situations!

    or:

    • YYYY-MM-DDTHH:MM:SS for dates and times – note here: this format has dashes.

    This is valid for SQL Server 2000 and newer.

    If you use SQL Server 2008 and the DATE datatype (only DATE – not DATETIME!), then you can indeed also use the YYYY-MM-DD format and that will work, too, with any settings in your SQL Server.

    Don’t ask me why this whole topic is so tricky and somewhat confusing – that’s just the way it is. But with the YYYYMMDD format, you should be fine for any version of SQL Server and for any language and dateformat setting in your SQL Server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm test building a scraping site with django. For some reason the following code
I am building a console application that gathers some data and then sends it
I've been put in charge of building some tools to help end-user test why
I have a spreadsheet that I am importing that contains some test data for
I'm building a test app on AWS. I have a 'master' machine that owns
I am building some small Java application to run on Goole AppEngine. It is
I am building some basic HTML code for a CMS. One of the page-related
We are dynamically building some SQL statements and we are utilizing the IN operator.
I'm building a small GUI-Test automation tool in C# for a application. One of
I'm building a Magento shop for a client, I uploaded some test images for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.