Jump to content
mfig

converter data

Recommended Posts

mfig

Como converto um campo no sql do tipo date para data normal, é que me aparece numa textbox assim 3/20/2011 12:00:00 AM

e queria converter para dia/mes/ano.

Share this post


Link to post
Share on other sites
Rechousa

Olá,

O que pretendes é isto:

DateTime dt = DateTime.Now.ToString("dd-MM-yyyy");

Mas, pessoalmente, prefiro usar o formato Ano-Mes-Dia. Já tive chatices com outros formatos, incluindo esse ;)


Pedro Martins

Sharing is Knowledge!

http://www.linkedin.com/in/rechousa

Share this post


Link to post
Share on other sites
Rechousa

Desculpa, acho que li mal a tua pergunta...

À pouco dei-te a versão C#, mas o que pretendes (pelo que percebi da 2a vez) é como o fazer em T-SQL.

Pois bem:

PRINT CONVERT(CHAR(10), GETDATE(), 105)


Pedro Martins

Sharing is Knowledge!

http://www.linkedin.com/in/rechousa

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.