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 7557831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:14:04+00:00 2026-05-30T12:14:04+00:00

All my columns are varchar so I used common expression table to convert [Column

  • 0

All my columns are varchar so I used common expression table to convert [Column 0] to datetime since [Column 0] contains date in this format 2012-02-28 00:00:08.000

WITH pss AS 
(
select CONVERT(datetime, [Column 0]) as t, [Column 1], [Column 2], [Column 3], [Column 4], [Column 5], [Column 6]
from PWS where [Column 0]  like '%2/28%'
)
select *from pss where datepart(HOUR,[t]) >= '11' AND datepart(HOUR,[t]) <= '12'

I am getting the following message

Msg 242, Level 16, State 3, Line 1
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

  • 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-30T12:14:06+00:00Added an answer on May 30, 2026 at 12:14 pm

    You also need to provide the hint with CONVERT as to the structure of the date within a varchar. The ymd sequence will be recognised as 102:

    convert(datetime, '2012-02-28 00:00:08.000', 102)
    

    See http://msdn.microsoft.com/en-us/library/ms187928.aspx for a description of CONVERT and the available datetime styles

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

Sidebar

Related Questions

I want to get table metadata for all table columns. Like type string(varchar2)/int/float/datetime and
I'm doing dynamic SQL to convert all columns in a table a string so
I have a SQL Server 2000 database with a column of type VARCHAR(255). All
I want to query the name of all columns of a table. I found
I have table named 'Dictionary' with columns as follow: ID bigint TYPE varchar (200)
I have a table named activity with 2 columns: when as datetime // last
I have some data which is stored in a VARCHAR(MAX) column that contains the
Consider this classical setup: entry table: id (int, PK) title (varchar 255) entry_category table:
How to select all columns from tables in join using linq Sql: select CTRL_RUN_JOB.*,
I need to select all columns from two tables, but need to be able

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.