Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 26th, 2006, 09:29 AM
Authorized User
 
Join Date: Feb 2006
Location: Bluefields, , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAKO
Default Problem with DateTime and Textbox

I need to format text from two textboxes to use as DateTime type to filter in a DB Query. In other words, I need to pass the text date-like formatted to add it to the SELECT command to filter registries in the range of dates. Thanks in advance for any help whatsoever!!




MAKO - "El super simio"
__________________
MAKO - \"El super simio\"
Reply With Quote
  #2 (permalink)  
Old July 26th, 2006, 09:57 AM
Authorized User
 
Join Date: Apr 2006
Location: Jamnagar, Gujarat, India.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vivekshah Send a message via Yahoo to vivekshah
Default

All depends on what Database your using to store data.?
You nedd to convert the text box value to datetime format first .

For Ex:
DateTime fromdate = Convert.ToDateTime(txtStartDate.Text);

Hope this will solve your problem to filter the data.



Vivek Shah
Reply With Quote
  #3 (permalink)  
Old July 26th, 2006, 10:05 AM
Authorized User
 
Join Date: Feb 2006
Location: Bluefields, , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAKO
Default

Yes, it kinda helps a lot, but I tried this already and the datetime result is in the wrong format MM/dd/yyyy and I need the datetime value in format dd/MM/yyyy. Now there is an overload of the Convert.ToDateTime() Method that takes an IFormatProvider object. I don´t know how to use that overload, do you?

Thanks,

:)

MAKO - "El super simio"
Reply With Quote
  #4 (permalink)  
Old July 27th, 2006, 02:34 AM
Authorized User
 
Join Date: Apr 2006
Location: Jamnagar, Gujarat, India.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vivekshah Send a message via Yahoo to vivekshah
Default

You can do one thing that

Ex:

DateTime fromdate = Convert.ToDateTime(txtStartDate.Text);

DateTime fromNew = fromdate.ToString("dd/mm/yyyy");

You will ge the date format in dd/mm/yyyy format in the variable fromNew.

Hope this will solve your problem.

Good Luck

Vivek Shah
Reply With Quote
  #5 (permalink)  
Old July 28th, 2006, 12:24 AM
Friend of Wrox
 
Join Date: May 2006
Location: Delhi, Delhi, India.
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To give user more ease we generally use three combobox, 1 for date part, 2nd for month and 3rd for year to chose.This solve many issues.

Bijgupt
Reply With Quote
  #6 (permalink)  
Old July 28th, 2006, 10:09 AM
Authorized User
 
Join Date: Feb 2006
Location: Bluefields, , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAKO
Default

Thanks a lot, guys! Your postings were of much help!

I took the string from the textboxes and converted it to datetime datatype inside a function that returns that datetime variable as a string with dd/MM/yyyy format. Just as vivek shah showed me. Thanks, Vivek!

You Rock, dudes!!



MAKO - "El super simio"
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DateTime Problem kwilliams ASP.NET 2.0 Professional 1 March 12th, 2008 01:36 PM
problem with dateTime picker roy_mm Reporting Services 2 March 14th, 2007 11:34 AM
Datetime problem hastikeyvan Dreamweaver (all versions) 16 January 25th, 2006 11:58 AM
DateTime problem acko Pro VB Databases 7 October 31st, 2004 05:53 AM



All times are GMT -4. The time now is 05:58 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.