• Varchar to Date SQL SERVER

    Author
    Topic
    #479710

    Hi folks, am a newbie to SQL server and finding it difficult to convert a varchar field to date (was easy in Access!)

    I have a field in Table1 called Opened which gives a string dd/mm/yyyy in varchar (10) format.

    I wish to convert this to date and have tried various methods all of which don’t work. e.g.

    ALTER[/COLOR][/SIZE] TABLE[/COLOR][/SIZE] dbo.[/COLOR][/SIZE]Table1
    ALTER[/COLOR][/SIZE] COLUMN[/COLOR][/SIZE] OPENED date

    I have also tried CONVERT CAST without success.

    I’m sure its easy when you know how – can anyone help?

    Thanks so much

    blitz[/COLOR][/SIZE]

    Viewing 1 reply thread
    Author
    Replies
    • #1303951

      You want to convert it to a Date to insert in a table or just to perform some calculation?

      • #1303955

        You want to convert it to a Date to insert in a table or just to perform some calculation?

        Hi I am going to search for records between dates.

        thanks.

    • #1303956

      You can use

      Code:
      [FONT font="Courier New"][COLOR=fuchsia]convert[/COLOR][COLOR=gray]([/COLOR][COLOR=blue]datetime[/COLOR][COLOR=gray],[/COLOR] [COLOR=red]YourDateValueAsAString[/COLOR][COLOR=gray],[/COLOR]103[COLOR=gray])
      

      [/COLOR][/FONT]

    Viewing 1 reply thread
    Reply To: Varchar to Date SQL SERVER

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: