Results 1 to 4 of 4

Thread: All the date functions in VB6

  1. #1
    Guest

    Question

    Does somebody know all the (Date) functions aviable in Vb6?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Just look up Date Function on your msdn disk..it should list them in the index.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    There is a bunch of them, they are listed in a book I have at home (I'm at work right now). The ones that stand out off the top of my head are:
    DateDiff, DateAdd, CDate, Date, Time, Now, Weekday, WeekdayName, Month, Day, Year.

    The Format$ function of course provides a variety of ways to format a date.
    "It's cold gin time again ..."

    Check out my website here.

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'have fun...

    Code:
    'just the basics..there are plenty more
    
    Function:
    
    Day  Function:                        CDate(expression)
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    Type Function:  	Date Data Type
          
    
    Date variables are stored as IEEE 64-bit (8-byte) floating-point 
    numbers that represent dates ranging from 1 January 100 to 31 
    December 9999 and times from 0:00:00 to 23:59:59. Any recognizable 
    literal date values can be assigned to Date variables.Date literals 
    must be enclosed within number signs (#), for example, 
    #January 1, 1993# or #1 Jan 93#.
    
    Date variables display dates according to the short date format 
    recognized by your computer. Times display according to the time 
    format (either 12-hour or 24-hour) recognized by your computer.
    
    When othernumeric types are converted to Date, values to the 
    left of the decimal represent date information while values to 
    the right of the decimal represent time. Midnight is 0 and 
    midday is 0.5. Negative whole numbers represent dates before 30 
    December 1899.
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    Month Function
          
    
    Returns a Variant (Integer) specifying a whole number between 
    1 and 12, inclusive, representing the month of the year.
    
    Syntax
    
    Month(date)
    
    The required dateargument is anyVariant,numeric expression,
    string expression, or any combination, that can represent a date. 
    If date containsNull, Null is returned.
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    		     
    Now Function
          
    
    Returns a Variant (Date) specifying the current date and 
    time according your computer's system date and time.
    
    Syntax
    
    Now
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    Weekday Function
          
    
    Returns a Variant (Integer) containing a whole number representing 
    the day of the week.
    
    Syntax
    
    Weekday(date, [firstdayofweek])
    
    The Weekday function syntax has thesenamed arguments:
    
    Part Description 
    date Required.Variant,numeric expression,string expression, or 
    any combination, that can represent a date. If date containsNull, 
    Null is returned. 
    firstdayofweek Optional. Aconstant that specifies the first day 
    of the week. If not specified, vbSunday is assumed. 
    
    
    Settings
    
    The firstdayofweek argument has these settings:
    
    Constant Value Description 
    vbUseSystem 0 Use the NLS API setting. 
    vbSunday 1 Sunday (default) 
    vbMonday 2 Monday 
    vbTuesday 3 Tuesday 
    vbWednesday 4 Wednesday 
    vbThursday 5 Thursday 
    vbFriday 6 Friday 
    vbSaturday 7 Saturday 
    
    
    Return Values
    
    The Weekday function can return any of these values:
    
    Constant Value Description 
    vbSunday 1 Sunday 
    vbMonday 2 Monday 
    vbTuesday 3 Tuesday 
    vbWednesday 4 Wednesday 
    vbThursday 5 Thursday 
    vbFriday 6 Friday 
    vbSaturday 7 Saturday 
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    Year Function
          
    
    Returns a Variant (Integer) containing a whole number representing 
    the year.
    
    Syntax
    
    Year(date)
    
    The required dateargument is anyVariant,numeric expression,
    string expression, or any combination, that can represent a date. 
    If date containsNull, Null is returned.
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    Format Function
          
    
    Returns a Variant (String) containing anexpression formatted 
    according to instructions contained in a format expression.
    
    Syntax
    
    Format(expression[, format[, firstdayofweek[, firstweekofyear]]])
    
    The Format function syntax has these parts:
    
    Part Description 
    expression Required. Any valid expression. 
    format Optional. A valid named or user-defined format expression. 
    firstdayofweek Optional. Aconstant that specifies the first day 
    of the week. 
    firstweekofyear Optional. A constant that specifies the first week 
    of the year. 
    
    
    Settings
    
    The firstdayofweekargument has these settings:
    
    Constant Value Description 
    vbUseSystem 0 Use NLS API setting. 
    VbSunday 1 Sunday (default) 
    vbMonday 2 Monday 
    vbTuesday 3 Tuesday 
    vbWednesday 4 Wednesday 
    vbThursday 5 Thursday 
    vbFriday 6 Friday 
    vbSaturday 7 Saturday 
    
    
    The firstweekofyear argument has these settings:
    
    Constant Value Description 
    vbUseSystem 0 Use NLS API setting. 
    vbFirstJan1 1 Start with week in which January 1 occurs (default). 
    vbFirstFourDays 2 Start with the first week that has 
    at least four days in the year. 
    vbFirstFullWeek 3 Start with the first full week of the year. 
    
    
    Remarks
    
    To Format Do This 
    Numbers Use predefined named numeric formats or create user-defined 
    numeric formats. 
    Dates and times Use predefined named date/time formats or create 
    user-defined date/time formats. 
    Date and time serial numbers Use date and time formats or numeric 
    formats. 
    Strings Create your own user-defined string formats. 
    
    
    If you try to format a number without specifying format, Format 
    provides functionality similar to the Str function, although it is 
    internationally aware. However, positive numbers formatted as 
    strings using Format don’t include a leading space reserved for 
    the sign of the value; those converted using Str retain the leading 
    space.
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Type Conversion
    
    CDate(expression)
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    DateAdd Function
          
    
    Returns a Variant (Date) containing a date to which a specified 
    time interval has been added.
    
    Syntax
    
    DateAdd(interval, number, date)
    
    The DateAdd function syntax has thesenamed arguments:
    
    Part Description 
    interval Required.String expression that is the interval of time 
    you want to add. 
    number Required.Numeric expression that is the number of intervals 
    you want to add. It can be positive (to get dates in the future) or 
    negative (to get dates in the past). 
    date Required. Variant (Date) or literal representing date to which 
    the interval is added. 
    
    
    Settings
    
    The intervalargument has these settings:
    
    Setting Description 
    yyyy Year 
    q Quarter 
    m Month 
    y Day of year 
    d Day 
    w Weekday 
    ww Week 
    h Hour 
    n Minute 
    s Second 
    
    
    Remarks
    
    You can use the DateAdd function to add or subtract a specified time 
    interval from a date. For example, you can use DateAdd to calculate 
    a date 30 days from today or a time 45 minutes from now.
    
    To add days to date, you can use Day of Year ("y"), Day ("d"), or 
    Weekday ("w").
    
    The DateAdd function won't return an invalid date. The following 
    
    DateAdd("m", 1, "31-Jan-95")
    
    In this case, DateAdd returns 28-Feb-95, not 31-Feb-95. If date 
    is 31-Jan-96, it returns 29-Feb-96 because 1996 is a leap year.
    
    If the calculated date would precede the year 100 (that is, you 
    subtract more years than are in date), an error occurs.
    
    If number isn't aLong value, it is rounded to the nearest whole 
    number before being evaluated.
    
    Note   The format of the return value for DateAdd is determined 
    by Control Panel settings, not by the format that is passed in date 
    argument.
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    DateDiff Function
          
    
    Returns a Variant (Long) specifying the number of time intervals 
    between two specified dates.
    
    Syntax
    
    DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])
    
    The DateDiff function syntax has thesenamed arguments:
    
    Part Description 
    interval Required.String expression that is the interval of time you 
    use to calculate the difference between date1 and date2. 
    date1, date2 Required; Variant (Date). Two dates you want to use in 
    the calculation. 
    firstdayofweek Optional. Aconstant that specifies the first day of 
    the week. If not specified, Sunday is assumed. 
    firstweekofyear Optional. A constant that specifies the first week of 
    the year. If not specified, the first week is assumed to be the week 
    in which January 1 occurs. 
    
    
    Settings
    
    The intervalargument has these settings:
    
    Setting Description 
    yyyy Year 
    q Quarter 
    m Month 
    y Day of year 
    d Day 
    w Weekday 
    ww Week 
    h Hour 
    n Minute 
    s Second 
    
    
    The firstdayofweek argument has these settings:
    
    Constant Value Description 
    vbUseSystem 0 Use the NLS API setting. 
    vbSunday 1 Sunday (default) 
    vbMonday 2 Monday 
    vbTuesday 3 Tuesday 
    vbWednesday 4 Wednesday 
    vbThursday 5 Thursday 
    vbFriday 6 Friday 
    vbSaturday 7 Saturday 
    
    Constant Value Description 
    vbUseSystem 0 Use the NLS API setting. 
    vbFirstJan1 1 Start with week in which January 1 occurs (default). 
    vbFirstFourDays 2 Start with the first week that has at least four 
    days in the new year. 
    vbFirstFullWeek 3 Start with first full week of the year. 
    
    
    Remarks
    
    You can use the DateDiff function to determine how many specified 
    time intervals exist between two dates. For example, you might use 
    DateDiff to calculate the number of days between two dates, or the 
    number of weeks between today and the end of the year.
    
    To calculate the number of days between date1 and date2, you can 
    use either Day of year ("y") or Day ("d"). When interval is 
    Weekday ("w"), DateDiff returns the number of weeks between the 
    two dates. If date1 falls on a Monday, DateDiff counts the number 
    of Mondays until date2. It counts date2 but not date1. If interval 
    is Week ("ww"), however, the DateDiff function returns the number 
    of calendar weeks between the two dates. It counts the number of 
    Sundays between date1 and date2. DateDiff counts date2 if it falls 
    on a Sunday; but it doesn't count date1, even if it does fall on a 
    Sunday.
    
    If date1 refers to a later point in time than date2, the DateDiff 
    function returns a negative number.
    
    The firstdayofweek argument affects calculations that use 
    the "w" and "ww" interval symbols.
    
    If date1 or date2 is adate literal, the specified year becomes 
    a permanent part of that date. However, if date1 or date2 is 
    enclosed in double quotation marks (" "), and you omit the year, 
    the current year is inserted in your code each time the date1 
    or date2 expression is evaluated. This makes it possible to 
    write code that can be used in different years.
    
    When comparing December 31 to January 1 of the immediately 
    succeeding year, DateDiff for Year ("yyyy") returns 1 even 
    though only a day has elapsed.
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    DatePart Function
          
    
    Returns a Variant (Integer) containing the specified part of a 
    given date.
    
    Syntax
    
    DatePart(interval, date[,firstdayofweek[, firstweekofyear]])
    
    The DatePart function syntax has thesenamed arguments:
    
    Part Description 
    interval Required.String expression that is the interval of time 
    you want to return. 
    date Required. Variant (Date) value that you want to evaluate. 
    firstdayofweek Optional. Aconstant that specifies the first day 
    of the week. If not specified, Sunday is assumed. 
    firstweekofyear Optional. A constant that specifies the first week 
    of the year. If not specified, the first week is assumed to be the 
    week in which January 1 occurs. 
    
    
    Settings
    
    The intervalargument has these settings:
    
    Setting Description 
    yyyy Year 
    q Quarter 
    m Month 
    y Day of year 
    d Day 
    w Weekday 
    ww Week 
    h Hour 
    n Minute 
    s Second 
    
    
    The firstdayofweek argument has these settings:
    
    Constant Value Description 
    vbUseSystem 0 Use the NLS API setting. 
    vbSunday 1 Sunday (default) 
    vbMonday 2 Monday 
    vbTuesday 3 Tuesday 
    vbWednesday 4 Wednesday 
    vbThursday 5 Thursday 
    vbFriday 6 Friday 
    vbSaturday 7 Saturday 
    
    
    The firstweekofyear argument has these settings:
    
    Constant Value Description 
    vbUseSystem 0 Use the NLS API setting. 
    vbFirstJan1 1 Start with week in which January 1 occurs (default). 
    vbFirstFourDays 2 Start with the first week that has at least 
    four days in the new year. 
    vbFirstFullWeek 3 Start with first full week of the year. 
    
    
    Remarks
    
    You can use the DatePart function to evaluate a date and return a 
    specific interval of time. For example, you might use DatePart to 
    calculate the day of the week or the current hour.
    
    The firstdayofweek argument affects calculations that use 
    the "w" and "ww" interval symbols.
    
    If date is adate literal, the specified year becomes a permanent 
    part of that date. However, if date is enclosed in double quotation 
    marks (" "), and you omit the year, the current year is inserted in 
    your code each time the date expression is evaluated. This makes 
    it possible to write code that can be used in different years.
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    DateSerial Function
          
    
    Returns a Variant (Date) for a specified year, month, and day.
    
    Syntax
    
    DateSerial(year, month, day)
    
    The DateSerial function syntax has thesenamed arguments:
    
    Part Description 
    year Required; Integer. Number between 100 and 9999, 
    inclusive, or anumeric expression. 
    month Required; Integer. Any numeric expression. 
    day Required; Integer. Any numeric expression. 
    
    
    Remarks
    
    To specify a date, such as December 31, 1991, the range of 
    numbers for each DateSerialargument should be in the accepted 
    range for the unit; that is, 1–31 for days and 1–12 for months. 
    However, you can also specify relative dates for each argument 
    using any numeric expression that represents some number of days, 
    months, or years before or after a certain date.
    
    The following example uses numeric expressions instead of 
    absolute date numbers. Here the DateSerial function returns 
    a date that is the day before the first day (1 - 1), two months 
    before August (8 - 2), 10 years before 1990 (1990 - 10); 
    in other words, May 31, 1980.
    
    DateSerial(1990 - 10, 8 - 2, 1 - 1)
    
    For the year argument, values between 0 and 29, inclusive, 
    are interpreted as the years 2000–2029. Values between 30 
    and 99 are interpreted as the years 1930–1999. For all other 
    year arguments, use a four-digit year (for example, 1800).
    
    When any argument exceeds the accepted range for that argument, 
    it increments to the next larger unit as appropriate. For example, 
    if you specify 35 days, it is evaluated as one month and some number 
    of days, depending on where in the year it is applied. If any 
    single argument is outside the range -32,768 to 32,767, an error 
    occurs. If the date specified by the three arguments falls 
    outside the acceptable range of dates, an error occurs.
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    DateValue Function
          
    
    Returns a Variant (Date).
    
    Syntax
    
    DateValue(date)
    
    The required dateargument is normally astring expression 
    representing a date from January 1, 100 through December 31, 9999. 
    However, date can also be anyexpression that can represent a date, 
    a time, or both a date and time, in that range.
    
    Remarks
    
    If date is a string that includes only numbers separated by 
    validdate separators, DateValue recognizes the order for month, 
    day, and year according to the Short Date format you specified 
    for your system. DateValue also recognizes unambiguous dates 
    that contain month names, either in long or abbreviated form. 
    For example, in addition to recognizing 12/30/1991 and 12/30/91, 
    DateValue also recognizes December 30, 1991 and Dec 30, 1991.
    
    If the year part of date is omitted, DateValue uses the current 
    year from your computer's system date.
    
    If the date argument includes time information, DateValue 
    doesn't return it. However, if date includes invalid time 
    information (such as "89:98"), an error occurs.
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width