Connecting Tech Pros Worldwide Help | Site Map

how convert date to string

Newbie
 
Join Date: Apr 2007
Posts: 12
#1: Apr 12 '07
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's Avatar
Expert
 
Join Date: Nov 2006
Posts: 1,017
#2: Apr 12 '07

re: how convert date to string


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.
iburyak's Avatar
Expert
 
Join Date: Nov 2006
Posts: 1,017
#3: Apr 12 '07

re: how convert date to string


Quote:

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(smalldatetime, '12/04/2007')[/PHP]

Good Luck.
Reply