473,659 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1355
"Paulo" <pr*****@uol.co m.brwrote in message
news:eL******** ******@TK2MSFTN GP05.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.To String("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**@markNOSPA Mrae.netescreve u na mensagem
news:e8******** ******@TK2MSFTN GP06.phx.gbl...
"Paulo" <pr*****@uol.co m.brwrote in message
news:eL******** ******@TK2MSFTN GP05.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.To String("dd MMM yyyy");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 7 '07 #3
"Paulo" <pr*****@uol.co m.brwrote in message
news:%2******** ************@TK 2MSFTNGP02.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**@markNOSPA Mrae.netescreve u na mensagem
news:uj******** ******@TK2MSFTN GP05.phx.gbl...
"Paulo" <pr*****@uol.co m.brwrote in message
news:%2******** ************@TK 2MSFTNGP02.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.co m.brwrote in message
news:un******** ******@TK2MSFTN GP03.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.ToShor tDateString().

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.co m.brwrote in message
news:eL******** ******@TK2MSFTN GP05.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******** ********@TK2MSF TNGP03.phx.gbl. ..
You got to cast ot DateTime first
Text.text = ((DateTime)read er['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
1914
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 format: dd/mm/yyyy hh:mm:ss. My doubt is, I can resolve this problem on which form? a) changing the Windows Regional Options b) setting the Internationalization classes of my AppDomain
138
5215
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 array(i.e)it will have the address of the first element.In the the program below am not able to increment the value stored in x,which is the address of the first element.Why am I not able to do that?Afterall 1 is also a hexadecimal number then...
1
1179
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 the table but i need the microseconds also to be inserted to my table.
3
1351
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 this 00 denotes which month. I want to store 01-12 (not 00-12 ) months. How can i do this ,i already change the date format with the above query but in that the 12th month denotes as 00. how can i change it. Please any one help to do this ...
1
1196
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 changing the color of the date value in that particular td of the table, i want to change the background color of tht td for tht date. please help me how to modify my code. its urgent. <xsl:template match="//row" > <xsl:variable name='JoinCntFlag'...
2
2537
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 portfolioscripdetails that table is having a column called portfolioscripid and portfolioscripdetailsid portfolioscripdetailsid is the auto generated column and portfoliscripid should be insert from portfolioscrip table
2
1428
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 are inserted The fields are->id(primary key) Item_id Date transaction(whether inward/outward) Price Quantity Total_amount Average
6
2845
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 . The error it is giving is date out of range (0..30). It is not converting date with 31 to its equvivalent epoch seconds. How to convert this into epoch seconds? Pls give me a solution. Thanks, Pavan
1
2014
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 date is 30/12/2010 week_end(last working day of the week) ='Y' month_end(last working day of month) ='Y' year_end (last working day of year) ='Y' This date always varies and depends on this date I need to set the flags to the remaining fields
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.