how convert date to string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sourabhmca
    New Member
    • Apr 2007
    • 12

    how convert date to string

    hi friend ,
    I took joindate field in table as smalldatetime type now I want to convert it in String type and formate is dd/mm/yyyy .how to convert it . and again i want to change this String type to date type .how can i do it
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    It depends on your server settings how datetime understood. Only string data representation can be changed.
    You can talk to your DBA to change datetime settings.

    Did you see my respond on VB forum to your same question?

    I don't understand why you don’t won't to do proper conversion that is recommended to use in these cases.


    Good Luck.

    Comment

    • iburyak
      Recognized Expert Top Contributor
      • Nov 2006
      • 1016

      #3
      Originally posted by sourabhmca
      hi friend ,
      I took joindate field in table as smalldatetime type now I want to convert it in String type and formate is dd/mm/yyyy .how to convert it . and again i want to change this String type to date type .how can i do it

      Wait, I maybe misunderstood your question.
      Do you want to convert string to datetime or datetime to string?

      To convert datetime to string do following.

      [PHP]select convert(varchar (20), getdate(), 103)[/PHP]

      To convert String to Datetime with Server available format

      [PHP]select convert(smallda tetime, '12/04/2007')[/PHP]

      Good Luck.

      Comment

      Working...