473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Doubt Date

Hi, how can I return just the date from a DateTime field ? Any C# .net 2.0 /
SQL function?

Thanks a lot!
Aug 7 '07 #1
7 1341
"Paulo" <pr*****@uol.com.brwrote in message
news:eL**************@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

Aug 7 '07 #2
But where do I put the reader['FieldName'] returned from the SQL Server ?

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netescreveu na mensagem
news:e8**************@TK2MSFTNGP06.phx.gbl...
"Paulo" <pr*****@uol.com.brwrote in message
news:eL**************@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

Aug 7 '07 #3
"Paulo" <pr*****@uol.com.brwrote in message
news:%2********************@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

Aug 7 '07 #4
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]" <ma**@markNOSPAMrae.netescreveu na mensagem
news:uj**************@TK2MSFTNGP05.phx.gbl...
"Paulo" <pr*****@uol.com.brwrote in message
news:%2********************@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

Aug 7 '07 #5
"Paulo" <pr*****@uol.com.brwrote in message
news:un**************@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

Aug 7 '07 #6
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" <pr*****@uol.com.brwrote in message
news:eL**************@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!

Aug 7 '07 #7
"George Ter-Saakov" <gt****@cardone.comwrote in message
news:%2****************@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

Aug 7 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Cesar Ronchese | last post by:
Hello All! I have a .Net project that, in my machine, the dates are showed in this format: dd/mm/yyyy. But, when I install the project in some customer machines, the date is showed in this...
138
by: ambika | last post by:
Hello, Am not very good with pointers in C,but I have a small doubt about the way these pointers work.. We all know that in an array say x,x is gonna point to the first element in that...
1
by: Murali Dharan | last post by:
Hi, Anyone help me in this problem. I want to insert date time with microseconds.... For example: Iam inserting value to the field using NOW(), the values of the date time is inserted to...
3
by: Geethu03 | last post by:
Hello In my table Date field contains the datatype Date.but i want to change the DateFormat as i requried,for this i used date_format(date,'%d-%m-%Y') The %m starts with the (00-12) In...
1
by: jai80 | last post by:
Hi Frenz, am working with xsl, and with a specific criteria, am trying to change the font color of the date value, as it can be seen from the code. Its a table with many rows. Instead of...
2
priyan
by: priyan | last post by:
hi all, I am having a doubt of how to write a function for my situation. I am having two tables portfolioscrip portfolioscripdetails i have to insert into...
2
by: divyac | last post by:
I am doing a project on inventory control of grocery items using PHP and mysql 5.In my project i have 2 tables.. 1.master_in_outs->where all the inward and outward transactions of particular items...
6
by: pavanponnapalli | last post by:
hi, i am using Date::Time and using localtime function to convert a given timestamp to epoch seconds. Everything is fine. The problem comes when we give date someting like 2008-11-31 04:45:45...
1
by: kimmybunn | last post by:
Doubt to write a SQL: I am having a table,with different fields such as date,week_end ,month_end,year_end etc depends on the date I need to update the flags of the reamaining fields eg: if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.