Doubt Date
Hi, how can I return just the date from a DateTime field ? Any C# .net 2.0 /
SQL function?
Thanks a lot!
Date:Tue, 7 Aug 2007 08:29:28 -0300
Author:
|
Re: Doubt Date
"Paulo" wrote in message
news:eLXWTZO2HHA.1208@TK2MSFTNGP05.phx.gbl...
> Hi, how can I return just the date from a DateTime field ? Any C# .net 2.0
> / SQL function?
string strDateOnly = DateTime.Now.ToString("dd MMM yyyy");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Tue, 7 Aug 2007 12:47:24 +0100
Author:
|
Re: Doubt Date
But where do I put the reader['FieldName'] returned from the SQL Server ?
"Mark Rae [MVP]" escreveu na mensagem
news:e8SkziO2HHA.1484@TK2MSFTNGP06.phx.gbl...
> "Paulo" wrote in message
> news:eLXWTZO2HHA.1208@TK2MSFTNGP05.phx.gbl...
>
>> Hi, how can I return just the date from a DateTime field ? Any C# .net
>> 2.0 / SQL function?
>
> string strDateOnly = DateTime.Now.ToString("dd MMM yyyy");
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
Date:Tue, 7 Aug 2007 09:05:04 -0300
Author:
|
Re: Doubt Date
"Paulo" wrote in message
news:%23f%23%23NtO2HHA.3788@TK2MSFTNGP02.phx.gbl...
> But where do I put the reader['FieldName'] returned from the SQL Server ?
You made no mention of a datareader in your original post...
Please explain exactly what you are trying to do...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Tue, 7 Aug 2007 13:16:09 +0100
Author:
|
Re: Doubt Date
Sorry my friend, what I need to do is return a DateTime field from SQL
Server 2000 and put it on a text box to the user edit, but when I do:
Text.text = reader['SomeField'].AsString;
shows: 06/08/2007 00:00:00
I need only: 06/08/2007 (dd/mm/aaaa) the Brasil format...
Can you understand me ?
Thanks
"Mark Rae [MVP]" escreveu na mensagem
news:ujWs3yO2HHA.1212@TK2MSFTNGP05.phx.gbl...
> "Paulo" wrote in message
> news:%23f%23%23NtO2HHA.3788@TK2MSFTNGP02.phx.gbl...
>
>> But where do I put the reader['FieldName'] returned from the SQL Server ?
>
> You made no mention of a datareader in your original post...
>
> Please explain exactly what you are trying to do...
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
Date:Tue, 7 Aug 2007 09:22:45 -0300
Author:
|
Re: Doubt Date
"Paulo" wrote in message
news:unLZG3O2HHA.2064@TK2MSFTNGP03.phx.gbl...
> Sorry my friend, what I need to do is return a DateTime field from SQL
> Server 2000 and put it on a text box to the user edit, but when I do:
>
> Text.text = reader['SomeField'].AsString;
>
> shows: 06/08/2007 00:00:00
>
> I need only: 06/08/2007 (dd/mm/aaaa) the Brasil format...
>
Text.text = reader['SomeField'].ToString("dd/mm/aaaa");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Tue, 7 Aug 2007 13:47:10 +0100
Author:
|
Re: Doubt Date
Error 2 No overload for method 'ToString' takes '1' arguments C:\Documents
and Settings\SUPORTE\Meus documentos\Visual Studio
2005\WebSites\WebSite6\Produto.aspx.cs 275 39 C:\...\WebSite6\
"Mark Rae [MVP]" escreveu na mensagem
news:OSpNNEP2HHA.1184@TK2MSFTNGP04.phx.gbl...
> "Paulo" wrote in message
> news:unLZG3O2HHA.2064@TK2MSFTNGP03.phx.gbl...
>
>> Sorry my friend, what I need to do is return a DateTime field from SQL
>> Server 2000 and put it on a text box to the user edit, but when I do:
>>
>> Text.text = reader['SomeField'].AsString;
>>
>> shows: 06/08/2007 00:00:00
>>
>> I need only: 06/08/2007 (dd/mm/aaaa) the Brasil format...
>>
>
> Text.text = reader['SomeField'].ToString("dd/mm/aaaa");
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
Date:Tue, 7 Aug 2007 10:04:30 -0300
Author:
|
Re: Doubt Date
String.Format() should work
or load into a DateTime object and use dateTime.ToShortDateString().
The String format is useful if you are dealing with one date format. The
DateTime is better if you have to be culture aware, as it respects the
culture of the thread.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)
************************************************
Think outside the box!
************************************************
"Paulo" wrote in message
news:eLXWTZO2HHA.1208@TK2MSFTNGP05.phx.gbl...
> Hi, how can I return just the date from a DateTime field ? Any C# .net 2.0
> / SQL function?
>
> Thanks a lot!
>
Date:Tue, 7 Aug 2007 08:18:02 -0500
Author:
|
Re: Doubt Date
You got to cast ot DateTime first
Text.text = ((DateTime)reader['SomeField']).ToString("dd/mm/aaaa");
George
"Paulo" wrote in message
news:uVIvaOP2HHA.4476@TK2MSFTNGP06.phx.gbl...
> Error 2 No overload for method 'ToString' takes '1' arguments C:\Documents
> and Settings\SUPORTE\Meus documentos\Visual Studio
> 2005\WebSites\WebSite6\Produto.aspx.cs 275 39 C:\...\WebSite6\
>
>
> "Mark Rae [MVP]" escreveu na mensagem
> news:OSpNNEP2HHA.1184@TK2MSFTNGP04.phx.gbl...
>> "Paulo" wrote in message
>> news:unLZG3O2HHA.2064@TK2MSFTNGP03.phx.gbl...
>>
>>> Sorry my friend, what I need to do is return a DateTime field from SQL
>>> Server 2000 and put it on a text box to the user edit, but when I do:
>>>
>>> Text.text = reader['SomeField'].AsString;
>>>
>>> shows: 06/08/2007 00:00:00
>>>
>>> I need only: 06/08/2007 (dd/mm/aaaa) the Brasil format...
>>>
>>
>> Text.text = reader['SomeField'].ToString("dd/mm/aaaa");
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net
>
>
Date:Tue, 7 Aug 2007 10:26:06 -0400
Author:
|
Re: Doubt Date
"George Ter-Saakov" wrote in message
news:%23Okxl7P2HHA.1208@TK2MSFTNGP03.phx.gbl...
> You got to cast ot DateTime first
> Text.text = ((DateTime)reader['SomeField']).ToString("dd/mm/aaaa");
D'oh! Apologies, everybody... :-(
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Tue, 7 Aug 2007 16:38:40 +0100
Author:
|