Windows Develop Bookmark and Share   
 index > Windows Forms General > Format a datetime value to remove time
 

Format a datetime value to remove time

Hi,

On my form I have a datetime selector, when I select that it selects the relevant date/time, eg 25/09/2009 14:40:03

Before I save this to the database, I want to get rid of the time part - ie I want to save 25/09/2009 00:00:00

How do I do it?

(Using VB)
GraemeP  Friday, September 25, 2009 1:42 PM
If you're saving it as a DateTime column, you can simply use the .Date property, which will save just the date, setting the time to midnight (with DateTime, you'll always have a time... having no time effectively sets the time to midnight).

If you need to format it using a format string, you can always look up DateTime format strings on google. The first two hits will be what you want.
Coding Light - Illuminated Ideas and Algorithms in Software
Coding Light Wiki �LinkedIn �ForumsBrowser
  • Marked As Answer byGraemeP Friday, September 25, 2009 2:30 PM
  •  
David M Morton  Friday, September 25, 2009 1:43 PM
If you're saving it as a DateTime column, you can simply use the .Date property, which will save just the date, setting the time to midnight (with DateTime, you'll always have a time... having no time effectively sets the time to midnight).

If you need to format it using a format string, you can always look up DateTime format strings on google. The first two hits will be what you want.
Coding Light - Illuminated Ideas and Algorithms in Software
Coding Light Wiki �LinkedIn �ForumsBrowser
  • Marked As Answer byGraemeP Friday, September 25, 2009 2:30 PM
  •  
David M Morton  Friday, September 25, 2009 1:43 PM

You can use google to search for other answers

Custom Search

More Threads

• 2d charts in C# based windows form
• links inside webbrowser control
• Looking for recommendation on a good WinForms demo capturing technology or service?
• Graphic.DrawString problem
• Drawing a simple line on a ListViewItem in a ListView?????
• using Control.Focus
• BindingNavigator not saving to the record that the fields display?
• Learning to position text when printing in VS2005
• given print a panel controls
• n00b c# form error