473,803 Members | 4,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drop the time in Date field.

This is for a Win form.

SP sends back the PostMark date to my datagrid, shows proper date in
datagrid. When user clicks on datagrid, the code sends the current row to
text box. The text box shows the date and 12:00:00 AM. How do I get rid of
the time?

My code below.

int rowNum = dgDealerInfo.Cu rrentCell.RowNu mber;
object Cell1 = dgDealerInfo[rowNum, 0];
object Cell2 = dgDealerInfo[rowNum, 1];
object Cell3 = dgDealerInfo[rowNum, 2];
object Cell4 = dgDealerInfo[rowNum, 3];
object Cell5 = dgDealerInfo[rowNum, 4];
string s = string.Format(C ell3 + System.Environm ent.NewLine + Cell4 +
System.Environm ent.NewLine + Cell5);
string s1 = string.Format(C ell1 + "");
string s2 = string.Format(C ell2 + "");
Nov 17 '05 #1
7 1832
Hi,

Use DateTime.ToShor tDateFormat();

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike L" <Ca***@nospam.n ospam> wrote in message
news:64******** *************** ***********@mic rosoft.com...
This is for a Win form.

SP sends back the PostMark date to my datagrid, shows proper date in
datagrid. When user clicks on datagrid, the code sends the current row to
text box. The text box shows the date and 12:00:00 AM. How do I get rid
of
the time?

My code below.

int rowNum = dgDealerInfo.Cu rrentCell.RowNu mber;
object Cell1 = dgDealerInfo[rowNum, 0];
object Cell2 = dgDealerInfo[rowNum, 1];
object Cell3 = dgDealerInfo[rowNum, 2];
object Cell4 = dgDealerInfo[rowNum, 3];
object Cell5 = dgDealerInfo[rowNum, 4];
string s = string.Format(C ell3 + System.Environm ent.NewLine + Cell4 +
System.Environm ent.NewLine + Cell5);
string s1 = string.Format(C ell1 + "");
string s2 = string.Format(C ell2 + "");

Nov 17 '05 #2
I get an error. "Cannot implicitly convert type 'object' to 'System.DateTim e'.

Here is my code.

DateTime Cell3 = dgDealerInfo[rowNum, 2];
ResultForm.SetT extBox(Cell3.To ShortDateString ());
dgDealerInfo[rowNum, 2] is a cell in my datagrid on my winform.
ResultForm.SetT extBox is a method on my winform
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Use DateTime.ToShor tDateFormat();

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Mike L" <Ca***@nospam.n ospam> wrote in message
news:64******** *************** ***********@mic rosoft.com...
This is for a Win form.

SP sends back the PostMark date to my datagrid, shows proper date in
datagrid. When user clicks on datagrid, the code sends the current row to
text box. The text box shows the date and 12:00:00 AM. How do I get rid
of
the time?

My code below.

int rowNum = dgDealerInfo.Cu rrentCell.RowNu mber;
object Cell1 = dgDealerInfo[rowNum, 0];
object Cell2 = dgDealerInfo[rowNum, 1];
object Cell3 = dgDealerInfo[rowNum, 2];
object Cell4 = dgDealerInfo[rowNum, 3];
object Cell5 = dgDealerInfo[rowNum, 4];
string s = string.Format(C ell3 + System.Environm ent.NewLine + Cell4 +
System.Environm ent.NewLine + Cell5);
string s1 = string.Format(C ell1 + "");
string s2 = string.Format(C ell2 + "");


Nov 17 '05 #3
Mike L <Ca***@nospam.n ospam> wrote:
I get an error. "Cannot implicitly convert type 'object' to 'System.DateTim e'.


So cast the expression to a DateTime before trying to use it as one.

(Looking back to your original code, using x+"" to convert x to a
string is pretty nasty - use x.ToString(), or Convert.ToStrin g(x).)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
You could also use:

DateTime myDate = DateTime.Now();
string.Format(" {0:d}", myDate);

--

Derek Davis
dd******@gmail. com

"Mike L" <Ca***@nospam.n ospam> wrote in message
news:64******** *************** ***********@mic rosoft.com...
This is for a Win form.

SP sends back the PostMark date to my datagrid, shows proper date in
datagrid. When user clicks on datagrid, the code sends the current row to
text box. The text box shows the date and 12:00:00 AM. How do I get rid
of
the time?

My code below.

int rowNum = dgDealerInfo.Cu rrentCell.RowNu mber;
object Cell1 = dgDealerInfo[rowNum, 0];
object Cell2 = dgDealerInfo[rowNum, 1];
object Cell3 = dgDealerInfo[rowNum, 2];
object Cell4 = dgDealerInfo[rowNum, 3];
object Cell5 = dgDealerInfo[rowNum, 4];
string s = string.Format(C ell3 + System.Environm ent.NewLine + Cell4 +
System.Environm ent.NewLine + Cell5);
string s1 = string.Format(C ell1 + "");
string s2 = string.Format(C ell2 + "");

Nov 17 '05 #5
Thank you.

I cleaned up my code.

int rowNum = dgDealerInfo.Cu rrentCell.RowNu mber;
string Cell1 = dgDealerInfo[rowNum, 0].ToString();
string Cell2 = dgDealerInfo[rowNum, 1].ToString();
string Cell3 = dgDealerInfo[rowNum, 2].ToString();
DateTime Cell4 = (DateTime) dgDealerInfo[rowNum, 3];
string Cell5 = dgDealerInfo[rowNum, 4].ToString();
string s = string.Format(C ell3 + System.Environm ent.NewLine +
string.Format(" {0:d}", Cell4) + System.Environm ent.NewLine + Cell5);
ResultForm.SetT extBox(s);

"Jon Skeet [C# MVP]" wrote:
Mike L <Ca***@nospam.n ospam> wrote:
I get an error. "Cannot implicitly convert type 'object' to 'System.DateTim e'.


So cast the expression to a DateTime before trying to use it as one.

(Looking back to your original code, using x+"" to convert x to a
string is pretty nasty - use x.ToString(), or Convert.ToStrin g(x).)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #6
Mike L <Ca***@nospam.n ospam> wrote:
Thank you.

I cleaned up my code.

int rowNum = dgDealerInfo.Cu rrentCell.RowNu mber;
string Cell1 = dgDealerInfo[rowNum, 0].ToString();
string Cell2 = dgDealerInfo[rowNum, 1].ToString();
string Cell3 = dgDealerInfo[rowNum, 2].ToString();
DateTime Cell4 = (DateTime) dgDealerInfo[rowNum, 3];
string Cell5 = dgDealerInfo[rowNum, 4].ToString();
string s = string.Format(C ell3 + System.Environm ent.NewLine +
string.Format(" {0:d}", Cell4) + System.Environm ent.NewLine + Cell5);
ResultForm.SetT extBox(s);


Why are you calling string.Format twice? What are you trying to
actually *format* by the time you've concatenated the various strings
together?

(You might want to consider more meaningful names than Cell1, Cell2,
Cell3 etc too.)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #7
I WAS calling string.Format twice because I'm still learning .Net programming.

I was using Cell name variables because I was still in draft stage. Now
that I know for sure what data I'm pulling through, I modified the variables.

int rowNum = dgDealerInfo.Cu rrentCell.RowNu mber;
string sFEI = dgDealerInfo[rowNum, 0].ToString();
string sSite = dgDealerInfo[rowNum, 1].ToString();
string sName = dgDealerInfo[rowNum, 2].ToString();
DateTime dtPostMark = (DateTime)
dgDealerInfo[rowNum, 3];
string sAmount = dgDealerInfo[rowNum, 4].ToString();
string s = sName + System.Environm ent.NewLine +
string.Format(" {0:d}", dtPostMark) + System.Environm ent.NewLine + sAmount;
ResultForm.SetT extBox(s);
ResultForm.SetD ealerFEI(Cell1) ;
ResultForm.SetD ealerSite(Cell2 );
this.DialogResu lt = DialogResult.OK ;
"Jon Skeet [C# MVP]" wrote:
Mike L <Ca***@nospam.n ospam> wrote:
Thank you.

I cleaned up my code.

int rowNum = dgDealerInfo.Cu rrentCell.RowNu mber;
string Cell1 = dgDealerInfo[rowNum, 0].ToString();
string Cell2 = dgDealerInfo[rowNum, 1].ToString();
string Cell3 = dgDealerInfo[rowNum, 2].ToString();
DateTime Cell4 = (DateTime) dgDealerInfo[rowNum, 3];
string Cell5 = dgDealerInfo[rowNum, 4].ToString();
string s = string.Format(C ell3 + System.Environm ent.NewLine +
string.Format(" {0:d}", Cell4) + System.Environm ent.NewLine + Cell5);
ResultForm.SetT extBox(s);


Why are you calling string.Format twice? What are you trying to
actually *format* by the time you've concatenated the various strings
together?

(You might want to consider more meaningful names than Cell1, Cell2,
Cell3 etc too.)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #8

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

Similar topics

2
11062
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic SFSB and, from there, to the database. On the front end, all cells appear as text fields. However, for certain cells, when the user clicks on the cell, the text field turns into a drop-down field (i.e. Select object), defaulting to the value...
0
2607
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot simutate it. Can anyone help? Thanks ************************** previous post: Message 1 in thread
4
4231
by: Mark Reed | last post by:
Hi all, I have a query (query1) which shows scan date, scan time & operator. One scan = 1 record. What I want to do is create a report based on query 2 from query1 which shows all the scans AND the difference between each scan. Something like below. I have spent days on this and can't figure it out. Date Time Login Diff 04-Dec-03 23:33:12 27478 04-Dec-03 23:33:38 27478...
2
9477
by: kmnotes04 | last post by:
Is it possible to link one drop-down box to another? For example, if a name is chosen from a drop-down list, can another drop-down list then automatically display the person's office as a result of the choice made in the first drop-down list? If so, how can that be done? I am working with 'Teach Yourself Microsoft Access' and I didn't see it discussed in that book (if it's even possible to do). Or would I just have to create linked tables...
2
1416
by: Woody Splawn | last post by:
I have a question about technique with regard to filling drop downs. I have a Winform that has several different tabs and tables associated with it. In an effort to keep the load time small I would like to not fill the fields with lookups at form load time. I have a grid on a tab of this form that has six fields in it that have lookups associated with them. By lookups I mean that the dropDown in the field is populated by doing a query...
5
102628
by: rs | last post by:
I have a table with a timestamp field which contains the date and time. ie. 9/13/2004 9:10:00 AM. I would like to split this field into 2 fields, one with just the DATE portion ie 9/13/2004 and the other with just the TIME portion. ie 9:10:00 AM. I can make the table view display what I want by placing the same data in 3 fields and setting the display property to 'General Date',' Medium Time' and 'Short Date' but the underlying data...
6
12563
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a calendar control to allow my users to enter a date but I need them to enter a time as well. It doesn't look like the calendar control will allow times to be entered so I was thinking of having two text boxes. One text box would contain the date...
3
12964
by: colleen1980 | last post by:
Hi: Data in my table is in that format. How to i separate date with time. 11/9/2006 10:10:46 AM Thank You.
1
1249
by: ndeeley | last post by:
Okay... I've created a drop down list fed by a table. I want my users to select an item in the list, say `Awaiting Repairs`, then fill in a single date text field. When a command button is pressed Access takes this date and fills in one of six disabled text boxes below (ie the one relating to the item in the list). I can do this for one item in the list, but I can't get Access to recognise the change of item in the list box - say to...
5
1709
by: Mark B | last post by:
I'd like to have a field in a gridview (or standalone on a webpage) that not only drops down each salespersons name but also precedes their name with a blue, red, green or orange dot icon depicting what group they belong to. Can drop-downs have such graphics as opposed to just text? TIA
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
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...
1
10289
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,...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7600
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
5496
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
4274
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
3
2968
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.