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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:20:14+00:00 2026-06-17T21:20:14+00:00

I have a table with a varchar column which represent date and time in

  • 0

I have a table with a varchar column which represent date and time in the next format:

dd/MM/yy hh:mm

For example: 27/01/13 07:57

I need to convert this column to DateTime type.

I tried to do it without success.

Assume that @varcharDT contains the VarChar DateTime and I want insert the converted value to @dateTimeDT variable.

DECLARE @varcharDT varchar(1000)
SELECT @varcharDT = dateTimeColumn from dbo.tempTable

--Trying to convert
DECLARE @dateTimeDT DateTime
SET @dateTimeDT= CONVERT (DATETIME, @varcharDT )

The last line raise the next exception:

Conversion failed when converting date and/or time from character string.

I think the conversion fails because my VarChar DateTime is in custom format.

How can I solve it?

I am working with SQL Server 2008 R2

Thanks

  • 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-06-17T21:20:15+00:00Added an answer on June 17, 2026 at 9:20 pm

    Try:

    CONVERT(datetime, @varcharDT, 3)
    

    The last number is the style for the convert. The list can be found in the MSDN documentation article CAST and CONVERT (Transact-SQL).

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

Sidebar

Related Questions

I have a varchar column which contains date in following format dd/mm/yyyy I need
So if I have a table as follows with column date datetime employee varchar
In a MySQL-table I have a VARCHAR -column with different values, which may represent
I have a table with a 'call open date' column (actual_log_date) which I convert,
I have a table in which date column is stores as varchar. while doing
I have a table which has a VARCHAR(MAX) column, and I need to change
I have a [Updates] table with [Version] column which is stored as a varchar
I have a single column table which looks like this: Gaming | Austria |
I have table with a XML column (called MetaData) which looks like this: <props>
I have a table which has two varchar(Max) columns Column 1 Column 2 -----------------------

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.