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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:30:28+00:00 2026-05-27T22:30:28+00:00

running : SELECT CONVERT(VARCHAR(20), GETDATE(), 100) will result : Jan 4 2012 1:25PM Ive

  • 0

running :

SELECT CONVERT(VARCHAR(20), GETDATE(), 100)

will result :

Jan  4 2012  1:25PM

Ive been knowing this for years.

However , yesterday, while I was driving , I thought to my self :

Hey! I gave him the format of 103 which is for datetime format ,

But I didnt actually TOLD the convert that Im passing also a datetime
object ! ( e.g. getdate()))

So ive tried :

SELECT CONVERT(VARCHAR(20), 'lalala', 100)

And the result was :

lalala

so , now Im trying to convert ‘lalala’ to string via datetime format (103).

which is ( by logic) should give me exception.

but it is not.

Any reasonable explanation ?

  • 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-27T22:30:28+00:00Added an answer on May 27, 2026 at 10:30 pm

    CONVERT takes into account both the target type and the expression’s type to see whether the third argument should be considered. If you are converting a datetime to a string or the other way round, the third argument is considered. In your example, a string is converted to a string and so the third argument is ignored.

    Consider this:

    SELECT 1, CONVERT(datetime, '03/01/2011', 103)
    SELECT 2, CONVERT(datetime, '03/01/2011', 101)
    SELECT 3, CONVERT(varchar, '03/01/2011', 103)
    SELECT 4, CONVERT(varchar, '03/01/2011', 101)
    

    Here are the results:

    --- -----------------------
    1   2011-01-03 00:00:00.000
    
    --- -----------------------
    2   2011-03-01 00:00:00.000
    
    --- ------------------------------
    3   03/01/2011
    
    --- ------------------------------
    4   03/01/2011
    

    As you can see, the last two ‘conversions’ didn’t change anything, because both the source and the target type were varchar, even though the expression did look like a date/datetime.

    Reference:

    • 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'm running this statement: declare @path varchar(255), @mydb varchar(50) SELECT @mydb = 'timeclockplus' select
I'm running this query: SELECT TOP 1 [DVD Copy].[Stock No] FROM [DVD Copy] WHERE
I'm running Mysql 5.0.77 and I'm pretty sure this query should work? SELECT *
I'm running a select that returns alphanumeric results, e.g: ABC-1 ABC-2 ABC-10 SAM-1 SAM-2
I currently have the query running on Postgres: SELECT * FROM addenda.users WHERE users.username
I'm currently running the following query: SELECT * from people WHERE id = 4;
I'm running the following query in Hypersonic DB (HSQLDB): SELECT (CASE foo WHEN 'a'
I'm running into a problem when trying to select records from my 2005 MS-SQL
I'm running the following code to get a random entry from a dictionary: SELECT
I am trying to have a running average column in the SELECT statement based

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.