Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Way to get just date value from DateTimePicker?

Status
Not open for further replies.

artyk

Programmer
Apr 5, 2006
163
US
Hi, I'm using several DateTimePickers in a form all of which display a date and time. One of the calculations that needs to be done requires matching records of the same date. If I try to compare those values as is the database will never find a match because it also has the time attached to the date. Is there a quick and easy way to get just the date or just the time from the control? I tried a Format statement, but it was asking for an extra parameter that I wasn't sure about. Thanks.
 
Format(DateTimePicker1, "Short Date")



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Me.DateTimePicker1.Value.ToShortDateString or
Me.DateTimePicker1.Value.ToShortTimeString

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Try having fun with these properties:

Code:
        DateTimePicker1.Value.Date

        DateTimePicker1.Value.Year
        DateTimePicker1.Value.Month
        DateTimePicker1.Value.Day

        DateTimePicker1.Value.Hour
        DateTimePicker1.Value.Minute
        DateTimePicker1.Value.Second
 
Thanks to both of you for the suggestions. I'll give those a try.
 
Also, thanks to Mastakilla. Your post appeared as I was replying. I'll try out your suggestion also.
 
OOPS!

My previous post should have read:

Format(DateTimePicker1[red].Value[/red], "Short Date")

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top