What If You Just Want the Time Portion?

Started by sukishan, Sep 04, 2009, 04:37 PM

Previous topic - Next topic

sukishan

What If You Just Want the Time Portion?
To retrieve just the date portion of a date/time value, use the built-in DateValue function. This function, discussed in the section "Converting Text to Date/Time Format" later in this chapter, takes in either a string or a date value and returns only the date portion. Using DateValue, you can compare the date portion of a Date variable to a specific date value, like this:

If DateValue(dtmSomeDate) = #5/14/70# Then
    ' You know the date portion of dtmSomeDate is 5/14/70
End IfOn the other hand, if you need just the time portion of a date variable, you can use the TimeValue function. Using this function, you could write code that checks the time portion of a date variable against a particular time, like this:

If TimeValue(dtmSomeDate) > #1:00 PM# Then
    ' You know the date variable contained a date portion
    ' with a time after 1:00 PM.
End If© 1997 by SYBEX Inc. All rights reserved.
A good beginning makes a good ending

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview