News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

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