Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Date-Time Functions – DateSerial()

Description:

The Date­Se­r­ial() func­tion returns the Date type based on the para­me­ters pro­vided (year, month and date).

Format:

DateSerial(year,month,day)

Arguments:
    • Year
      • Manda­tory
      • Type: Numeric or Any Numeric Expression
      • Between 100 and 9999, val­ues between 0–99 will be con­sid­ered as 1900–1999

  • Month
    • Manda­tory
    • Type: Numeric or Any Numeric Expression
    • If it’s greater than 12, than respec­tive num­ber will be added to the date, Exam­ple say 13, mean month will be Jan­u­ary and year will be increased by one.
  • Date
    • Manda­tory
    • Type: Numeric or Any Numeric Expression
    • If it’s greater than 31 and month is 12, than respec­tive num­ber will be added to the date, Exam­ple say 44, mean month will be Jan­u­ary and year will be increased by one and date will be 13.

Exam­ple:

Function FnDateSerial()

   Dim varYear

   Dim varMonth

   Dim varDate

    varYear = "2013"

    varMonth = "12"

    varDate = "44"

    

    strDate = DateSerial(varYear, varMonth, varDate)    

  MsgBox "Date is " & strDate

End Function

The Date­Se­r­ial() func­tion returns the Date type based on the para­me­ters pro­vided (year, month and date).

Date­Se­r­ial()

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: