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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:42:51+00:00 2026-05-31T14:42:51+00:00

I have a common field in a database table on SQL Server 2008. The

  • 0

I have a common field in a database table on SQL Server 2008. The type on the field is nvarchar(255). That field holds a number of different types of values coming from an application.

I currently have need to turn values in the field from a format of “Jul 19 2011 12:00AM” for example to a format of “2011-07-19 00:00:00.000”.

I know I can get this back in a query format with the statement:

SELECT CONVERT(datetime, value, 121)
  FROM [Table]
  where ...

This gives me a display format that I am looking for, but when I try to update the table with the corrected format using the following query, it converts it back to the “Jul 19 2011 12:00AM” format.

Update query:

Update [Table]
  set Value = CONVERT(datetime, t2.value, 121)
  from [Table] t1
  inner join
  (SELECT ID, CONVERT(datetime, value, 121) as value
  FROM [Table]) t2
  on t2.ID = t1.ID

Is there any way to force the destination nvarchar(255) field to maintain the “2011-07-19 00:00:00.000” format specified from the convert?

  • 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-31T14:42:52+00:00Added an answer on May 31, 2026 at 2:42 pm

    Using something like this, changing getdate() by your date field:

    select cast(datepart(yyyy,getdate()) as char(4)) + '-' 
            + replace(str(datepart(mm,getdate()),2),' ','0') + '-'
            + replace(str(datepart(dd,getdate()),2),' ','0') + ' '
            + replace(str(datepart(hh,getdate()),2),' ','0') + ':'
            + replace(str(datepart(mi,getdate()),2),' ','0') + ':'
            + replace(str(datepart(ss,getdate()),2),' ','0') + '.'
            + replace(str(datepart(ms,getdate()),3),' ','0')
    

    You can find it comfortable to make a function to get this format.

    Please read carefully the question before marking it as a bad question. “Store a date in nvarchar field”. This man wants to store a date as “TEXT” in a field, with the format he wants!! Please, be more careful.

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

Sidebar

Related Questions

Working with SQL Server 2008 R2. I have a table of hierarchical data, with
We have a common problem of moving our development SQL 2005 database onto shared
I have a mysql database that has 2 table. the first table contains the
I have unstructured geneally unclean data in a database field. There are common structures
We have a web application that is built on top of a SQL database.
I have a database table for users which contains common fields like password, email
I have a legacy database that includes a field 'User_Defined' containing a string describing
It's common to have a table where for example the the fields are account,
I have common functionality that I need to access from all screens of my
i have several common elements (components), that will generate some html. it seems my

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.