$show=home

VBA - Date-Time Function

VBA - Date-Time Function Shout4Education
VBScript Date and Time Functions help the developers to convert date and time from one format to another or to express the date or time value in the format that suits a specific condition.

Date Functions

Sr.No.Function & Description
1Date
A Function, which returns the current system date.
2CDate
A Function, which converts a given input to date.
3DateAdd
A Function, which returns a date to which a specified time interval has been added.
4DateDiff
A Function, which returns the difference between two time period.
5DatePart
A Function, which returns a specified part of the given input date value.
6DateSerial
A Function, which returns a valid date for the given year, month, and date.
7FormatDateTime
A Function, which formats the date based on the supplied parameters.
8IsDate
A Function, which returns a Boolean Value whether or not the supplied parameter is a date.
9Day
A Function, which returns an integer between 1 and 31 that represents the day of the specified date.
10Month
A Function, which returns an integer between 1 and 12 that represents the month of the specified date.
11Year
A Function, which returns an integer that represents the year of the specified date.
12MonthName
A Function, which returns the name of the particular month for the specified date.
13WeekDay
A Function, which returns an integer(1 to 7) that represents the day of the week for the specified day.
14WeekDayName
A Function, which returns the weekday name for the specified day.

VBA - Date Function

The Function returns the current system date.

Syntax

date()

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   Dim a as Variant
   a = date()
   msgbox "The Value of a : " & a
End Sub
When you execute the function, it produces the following output.
The Value of a : 08/04/2020 

VBA - CDate Function

The Function converts a valid date and time expression to type date.

Syntax

cdate(date)

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   Dim a as Variant
   Dim b as Variant
   
   a = cdate("Jan 01 2020")
   msgbox("The Value of a : " & a)
   
   b = cdate("31 Dec 2050")
   msgbox("The Value of b : " & b)
End Sub
When you execute the function, it produces the following output.
The Value of a : 1/01/2020
The Value of b : 31/12/2050 

VBA - DateAdd Function

A Function, which returns a date to which a specified time interval has been added.

Syntax

DateAdd(interval,number,date) 

Parameter Description

  • Interval − A required parameter. It can take the following values.
    • d - day of the year
    • m - month of the year
    • y - year of the year
    • yyyy - year
    • w - weekday
    • ww - week
    • q - quarter
    • h - hour
    • m - minute
    • s - second
  • Number − A required parameter. It can take both positive and negative parameters.
  • Date − A required parameter. A variant or literal representing the date to which an interval is added.

Example

Private Sub Constant_demo_Click()
   ' Positive Interal
   date1 = 27-Jun-1894
   msgbox("Line 1 : " &DateAdd("yyyy",1,date1))
   msgbox("Line 2 : " &DateAdd("q",1,date1))
   msgbox("Line 3 : " &DateAdd("m",1,date1))
   msgbox("Line 4 : " &DateAdd("y",1,date1))
   msgbox("Line 5 : " &DateAdd("d",1,date1))
   msgbox("Line 6 : " &DateAdd("w",1,date1))
   msgbox("Line 7 : " &DateAdd("ww",1,date1))
   msgbox("Line 8 : " &DateAdd("h",1,"01-Jan-2013 12:00:00"))
   msgbox("Line 9 : " &DateAdd("n",1,"01-Jan-2013 12:00:00"))
   msgbox("Line 10 : "&DateAdd("s",1,"01-Jan-2013 12:00:00"))
  
   ' Negative Interval
   msgbox("Line 11 : " &DateAdd("yyyy",-1,date1))
   msgbox("Line 12 : " &DateAdd("q",-1,date1))
   msgbox("Line 13 : " &DateAdd("m",-1,date1))
   msgbox("Line 14 : " &DateAdd("y",-1,date1))
   msgbox("Line 15 : " &DateAdd("d",-1,date1))
   msgbox("Line 16 : " &DateAdd("w",-1,date1))
   msgbox("Line 17 : " &DateAdd("ww",-1,date1))
   msgbox("Line 18 : " &DateAdd("h",-1,"01-Jan-2013 12:00:00"))
   msgbox("Line 19 : " &DateAdd("n",-1,"01-Jan-2013 12:00:00"))
   msgbox("Line 20 : " &DateAdd("s",-1,"01-Jan-2013 12:00:00")) 
End Sub
When you execute the above function, it produces the following output.
Line 1 : 27/06/1895
Line 2 : 27/09/1894
Line 3 : 27/07/1894
Line 4 : 28/06/1894
Line 5 : 28/06/1894
Line 6 : 28/06/1894
Line 7 : 4/07/1894
Line 8 : 1/01/2013 1:00:00 PM
Line 9 : 1/01/2013 12:01:00 PM
Line 10 : 1/01/2013 12:00:01 PM
Line 11 : 27/06/1893
Line 12 : 27/03/1894
Line 13 : 27/05/1894
Line 14 : 26/06/1894
Line 15 : 26/06/1894
Line 16 : 26/06/1894
Line 17 : 20/06/1894
Line 18 : 1/01/2013 11:00:00 AM
Line 19 : 1/01/2013 11:59:00 AM
Line 20 : 1/01/2013 11:59:59 AM

VBA - DateDiff Function

A Function, which returns the difference between two specified time intervals.

Syntax

DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]]) 

Parameter Description

  • Interval − A required parameter. It can take the following values.
    • d - day of the year
    • m - month of the year
    • y - year of the year
    • yyyy - year
    • w - weekday
    • ww - week
    • q - quarter
    • h - hour
    • m - minute
    • s - second
  • Date1 and Date2 − Required parameters.
  • Firstdayofweek − An optional parameter. Specifies the first day of the week. It can take the following values.
    • 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
    • 1 = vbSunday - Sunday
    • 2 = vbMonday - Monday
    • 3 = vbTuesday - Tuesday
    • 4 = vbWednesday - Wednesday
    • 5 = vbThursday - Thursday
    • 6 = vbFriday - Friday
    • 7 = vbSaturday - Saturday
  • Firstdayofyear − An optional parameter. Specifies the first day of the year. It can take the following values.
    • 0 = vbUseSystem - Use National Language Support (NLS) API setting
    • 1 = vbFirstJan1 - Start with the week in which January 1 occurs (default)
    • 2 = vbFirstFourDays - Start with the week that has at least four days in the new year
    • 3 = vbFirstFullWeek - Start with the first full week of the new year

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   Dim fromDate as Variant
   fromDate = "01-Jan-09 00:00:00"
   
   Dim toDate as Variant
   toDate = "01-Jan-10 23:59:00"
   
   msgbox("Line 1 : " &DateDiff("yyyy",fromDate,toDate))
   msgbox("Line 2 : " &DateDiff("q",fromDate,toDate))
   msgbox("Line 3 : " &DateDiff("m",fromDate,toDate))
   msgbox("Line 4 : " &DateDiff("y",fromDate,toDate))
   msgbox("Line 5 : " &DateDiff("d",fromDate,toDate))
   msgbox("Line 6 : " &DateDiff("w",fromDate,toDate))
   msgbox("Line 7 : " &DateDiff("ww",fromDate,toDate))
   msgbox("Line 8 : " &DateDiff("h",fromDate,toDate))
   msgbox("Line 9 : " &DateDiff("n",fromDate,toDate))
   msgbox("Line 10 : "&DateDiff("s",fromDate,toDate))
End Sub
When you execute the above function, it produces the following output.
Line 1 : 1
Line 2 : 4
Line 3 : 12
Line 4 : 365
Line 5 : 365
Line 6 : 52
Line 7 : 52
Line 8 : 8783
Line 9 : 527039
Line 10 : 31622340

VBA - DatePart Function

A Function, which returns the specific part of the given date.

Syntax

DatePart(interval,date[,firstdayofweek[,firstweekofyear]]) 

Parameter Description

  • Interval − A required parameter. It can take the following values.
    • d - day of the year.
    • m - month of the year
    • y - year of the year
    • yyyy - year
    • w - weekday
    • ww - week
    • q - quarter
    • h - hour
    • n - minute
    • s - second
  • Date1 − A required parameter.
  • Firstdayofweek − An optional parameter. Specifies the first day of the week. It can take the following values.
    • 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
    • 1 = vbSunday - Sunday
    • 2 = vbMonday - Monday
    • 3 = vbTuesday - Tuesday
    • 4 = vbWednesday - Wednesday
    • 5 = vbThursday - Thursday
    • 6 = vbFriday - Friday
    • 7 = vbSaturday - Saturday
  • Firstdayofyear − An optional parameter. Specifies the first day of the year. It can take the following values.
    • 0 = vbUseSystem - Use National Language Support (NLS) API setting
    • 1 = vbFirstJan1 - Start with the week in which January 1 occurs (default)
    • 2 = vbFirstFourDays - Start with the week that has at least four days in the new year
    • 3 = vbFirstFullWeek - Start with the first full week of the new year

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   Dim Quarter as Variant
   Dim DayOfYear as Variant
   Dim WeekOfYear as Variant
  
   Date1 = "2013-01-15"
   Quarter    = DatePart("q", Date1)
   
   msgbox("Line 1 : " & Quarter)
   DayOfYear  = DatePart("y", Date1)
   
   msgbox("Line 2 : " & DayOfYear)
   WeekOfYear = DatePart("ww", Date1)
   
   msgbox("Line 3 : " & WeekOfYear)
   msgbox("Line 4 : " & DatePart("m",Date1))  
End Sub
When you execute the above function, it produces the following output.
Line 1 : 1
Line 2 : 15
Line 3 : 3
Line 4 : 1 

VBA - DateSerial Function

A Function, which returns a date for the specified day, month, and year parameters.

Syntax

DateSerial(year,month,day)

Parameter Description

  • Year − A required parameter. A number between 100 and 9999 or a numeric expression. Values between 0 and 99 are interpreted as the years 1900 to 1999. For all other year arguments, use a complete four-digit year.
  • Month − A required parameter. It can also be in the form of an expression, which should range from 1 to 12.
  • Day − A required parameter. It can also be in the form of an expression, which should range from 1 to 31.

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox(DateSerial(2013,5,10))
End Sub
When you execute the above function, it produces the following output.
10/05/2014

VBA - Format DateTime Function

A Function, which helps the developers to format and return a valid date and time expression.

Syntax

FormatDateTime(date,format) 

Parameter Description

  • Date − A required parameter.
  • Format − An optional parameter. The Value that specifies the date or time format to be used. It can take the following values.
    • 0 = vbGeneralDate - Default
    • 1 = vbLongDate - Returns date
    • 2 = vbShortDate - Returns date
    • 3 = vbLongTime - Returns time
    • 4 = vbShortTime - Returns time

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   d = ("2013-08-15 20:25")
   msgbox("Line 1 : " & FormatDateTime(d))
   msgbox("Line 2 : " & FormatDateTime(d,1))
   msgbox("Line 3 : " & FormatDateTime(d,2))
   msgbox("Line 4 : " & FormatDateTime(d,3))
   msgbox("Line 5 : " & FormatDateTime(d,4))
End Sub   
When you execute the above function, it produces the following output.
Line 1 : 15/08/2013 8:25:00 PM 
Line 2 : Thursday, 15 August 2013
Line 3 : 15/08/2013
Line 4 : 8:25:00 PM
Line 5 : 20:25

VBA - IsDate Function

A Function, which returns a Boolean value whether or not the given input is a date.

Syntax

IsDate(expression)

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1 : " & IsDate("Nov 03, 1950"))
   msgbox("Line 2 : " & IsDate(#01/31/20#))
   msgbox("Line 3 : " & IsDate(#05/31/20 10:30 PM#))
End Sub
When you execute the above function, it produces the following output.
Line 1 : True
Line 2 : True
Line 3 : True 

VBA - Day Function

The Day function returns a number between 1 and 31 that represents the day of the specified date.

Syntax

Day(date) 

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox(Day("2013-06-30"))
End Sub
When you execute the above function, it produces the following output.
30

VBA - Month Function

The Month function returns a number between 1 and 12 that represents the month of the specified date.

Syntax

Month(date) 

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox(Month("2013-06-30"))
End Sub
When you execute the above function, it produces the following output.
6

VBA - Year Function

The Year function returns an integer that represents a year of the specified date.

Syntax

Year(date) 

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox(Year("2013-06-30"))
End sub
When you execute the above function, it produces the following output.
2013

VBA - Month Name

The MonthName function returns the name of the month for the specified date.

Syntax

MonthName(month[,toabbreviate]) 

Parameter Description

  • Month − A required parameter. It specifies the number of the month.
  • Toabbreviate − An optional parameter. A Boolean value that indicates if the month name is to be abbreviated. If left blank, the default value would be taken as False.

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1 : " & MonthName(01,True))
   msgbox("Line 2 : " & MonthName(01,false))
   msgbox("Line 3 : " & MonthName(07,True))
   msgbox("Line 4 : " & MonthName(07,false))
End Sub
When you execute the above function, it produces the following output.
Line 1 : Jan
Line 2 : January
Line 3 : Jul
Line 4 : July

VBA - WeekDay

The WeekDay function returns an integer from 1 to 7 that represents the day of the week for the specified date.

Syntax

Weekday(date[,firstdayofweek])  

Parameter Description

  • Date − A required parameter. The weekday will return a specified date.
  • Firstdayofweek − An optional parameter. Specifies the first day of the week. It can take the following values.
    • 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
    • 1 = vbSunday - Sunday
    • 2 = vbMonday - Monday
    • 3 = vbTuesday - Tuesday
    • 4 = vbWednesday - Wednesday
    • 5 = vbThursday - Thursday
    • 6 = vbFriday - Friday
    • 7 = vbSaturday - Saturday

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1: " & Weekday("2013-05-16",1))
   msgbox("Line 2: " & Weekday("2013-05-16",2))
   msgbox("Line 3: " & Weekday("2013-05-16",2))
   msgbox("Line 4: " & Weekday("2010-02-16"))
   msgbox("Line 5: " & Weekday("2010-02-17"))
   msgbox("Line 6: " & Weekday("2010-02-18"))
End Sub
When you execute the above function, it produces the following output.
Line 1: 5
Line 2: 4
Line 3: 4
Line 4: 3
Line 5: 4
Line 6: 5

VBA - WeekDay Name

The WeekDayName function returns the name of the weekday for the specified day.

Syntax

WeekdayName(weekday[,abbreviate[,firstdayofweek]]) 

Parameter Description

  • Weekday − A required parameter. The number of the weekday.
  • Toabbreviate − An optional parameter. A Boolean value that indicates if the month name is to be abbreviated. If left blank, the default value would be taken as False.
  • Firstdayofweek − An optional parameter. Specifies the first day of the week.
    • 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting
    • 1 = vbSunday - Sunday
    • 2 = vbMonday - Monday
    • 3 = vbTuesday - Tuesday
    • 4 = vbWednesday - Wednesday
    • 5 = vbThursday - Thursday
    • 6 = vbFriday - Friday
    • 7 = vbSaturday - Saturday

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1 : " &WeekdayName(3))
   msgbox("Line 2 : " &WeekdayName(2,True))
   msgbox("Line 3 : " &WeekdayName(1,False))
   msgbox("Line 4 : " &WeekdayName(2,True,0))
   msgbox("Line 5 : " &WeekdayName(1,False,1))
End Sub
When you execute the above function, it produces the following output.
Line 1 : Tuesday
Line 2 : Mon
Line 3 : Sunday
Line 4 : Tue
Line 5 : Sunday

Time Functions

Sr.No.Function & Description
1Now
A Function, which returns the current system date and time.
2Hour
A Function, which returns an integer between 0 and 23 that represents the hour part of the given time.
3Minute
A Function, which returns an integer between 0 and 59 that represents the minutes part of the given time.
4Second
A Function, which returns an integer between 0 and 59 that represents the seconds part of the given time.
5Time
A Function, which returns the current system time.
6Timer
A Function, which returns the number of seconds and milliseconds since 12:00 AM.
7TimeSerial
A Function, which returns the time for the specific input of hour, minute and second.
8TimeValue
A Function, which converts the input string to a time format.

VBA - Now Function

The Function Now returns the current system date and time.

Syntax

Now()

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   Dim a as Variant
   a = Now()
   msgbox("The Value of a : " & a)
End Sub
When you execute the above function, it produces the following output.
The Value of a : 19/07/2013 3:04:09 PM 

VBA - Hour Function

The Hour Function returns a number between 0 and 23 that represents the hour of the day for the specified time stamp.

Syntax

Hour(time) 

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1: " & Hour("3:13:45 PM"))
   msgbox("Line 2: " & Hour("23:13:45"))
   msgbox("Line 3: " & Hour("2:20 PM"))
End Sub
When you execute the above function, it produces the following output.
Line 1: 15
Line 2: 23
Line 3: 14 

VBA - Minute Function

The Minute Function returns a number between 0 and 59 that represents the minute of the hour for the specified time stamp.

Syntax

Minute(time) 

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1: " & Minute("3:13:45 PM"))
   msgbox("Line 2: " & Minute("23:43:45"))
   msgbox("Line 3: " & Minute("2:20 PM"))
End Sub
When you execute the above function, it produces the following output.
Line 1: 13
Line 2: 43
Line 3: 20

VBA - Second Function

The Second Function returns a number between 0 and 59 that represents the second of the hour for the specified time stamp.

Syntax

Second(time) 

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Line 1: " & Second("3:13:25 PM"))
   msgbox("Line 2: " & Second("23:13:45"))
   msgbox("Line 3: " & Second("2:20 PM"))
End Sub
When you execute the above function, it produces the following output.
Line 1: 25
Line 2: 45
Line 3: 0

VBA - Time Function

The Time Function returns the current system time.

Syntax

Time() 

Example

Private Sub Constant_demo_Click()
   msgbox("Line 1: " & Time())
End Sub
When you execute the above function, it produces the following output.
Line 1: 3:29:15 PM 

VBA - Timer Function

The Timer Function returns the number of seconds and milliseconds since 12:00 AM.

Syntax

Timer() 

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox("Time is : " & Now())
   msgbox("Timer is: " & Timer())
End Sub
When you execute the above function, it produces the following output.
Time is : 19/07/2013 3:45:53 PM
Timer is: 56753.4 

VBA - Time Serial Function

The TimeSerial function returns the time for the specified hour, minute, and second values.

Syntax

TimeSerial(hour,minute,second) 

Parameter Description

  • Hour − A required parameter, which is an integer between 0 and 23 or any numeric expression.
  • Minute − A required parameter, which is an integer between 0 and 59 or any numeric expression.
  • Second − A required parameter, which is an integer between 0 and 59 or any numeric expression.

Example

Add a button and add the following function.
Private Sub Constant_demo_Click()
   msgbox(TimeSerial(20,1,2))
   msgbox(TimeSerial(0,59,59))
   msgbox(TimeSerial(7*2,60/3,15+3))
End Sub
When you execute the above function, it produces the following output.
8:01:02 PM
12:59:59 AM
2:20:18 PM

VBA - Time Value Function

The TimeValue Function converts the given input string to a valid time.

Syntax

TimeValue(StringTime) 

Example

Add a button and add the following function.
Private Sub Constant_demo_Click() 
   msgbox(TimeValue("20:30"))
   msgbox(TimeValue("5:15"))
   msgbox(TimeValue("2:30:58"))
End Sub
When you execute the above function, it produces the following output.
8:30:00 PM
5:15:00 AM
2:30:58 AM


Comments

Blogger
Name

.NET_Interview,1,Accenture,1,Accenture News,1,Accenture_GFT,1,Accenture_Prep,1,Advance_Excel,22,Advance_Python,10,Advanced_Linux,6,Advanced_SQL,18,Advanced_Unix,6,AI,1,Alexa,1,Amazon,1,Amazon News,5,AMCAT,1,AMCAT_Prep,1,AMCAT_Solved_Papers,1,Ancient India,5,Android,1,Ansible,2,Apache_Sqoop,10,Aptitude,1,AWS,23,AWS CLI,6,AWS DeepRacer,1,AWS Tutorials,13,AWS_Dumps,1,AWS_Interview,1,AZ-104,1,AZ-900,2,Azure,3,Azure Administrator Associate,1,B_Tech,19,B.Tech,1,B.Tech Jobs,1,Backup,2,Banking Exam,1,Banking_Exam,1,Basic_Linux,29,Basic_Python,19,Basic_SQL,24,Basic_Unix,30,Best_Websites,1,Big_Data_Analytics,70,Blog,447,Blogger,3,Blogging,2,Blogspot,1,Books,2,BTech,20,C++_Interview,1,CBSE,93,Certification,5,Cheat Sheet,2,Civil_1st_Semester,1,Class 11,2,Class 11 Physics,2,Class 12,61,Class 12 Biology,16,Class 12 Chemistry,16,Class 12 English,14,Class 12 Physics,15,Class_12,28,Class_12_Chemistry,4,Class_12_Computer_Science,7,Class_12_Mathematics,1,Class_12_NCERT,15,Class_12_NCERT_Solutions,15,Class_12_Physics,18,Class_12_Physics_NCERT_Solutions,15,Class_12_Science,29,Cloud,2,Cloud_Service,1,CloudFormation,2,Coding,1,Cognizant News,1,Communication,2,Computer,18,Computer_Memory,2,Computer_Programming,2,Computer_Science,4,Control_System,9,Crack_Interview,3,CSE_5th_Semester,1,CSS,1,Data Analyst Jobs,1,Data Science,2,Data Science Interview,1,Data_Analytics,16,Data_Science,18,Data_Science_Interview,1,Database,47,Database Interview,2,Database_Interview,4,DP-900,1,Dumps,2,ECE_1st_Semester,1,ECE_1st_Year,1,ECE_4th_Semester,9,Electrical,2,Electrical_1st_Semester,1,Electronics,2,Electronics & Communication,1,Electronics_&_Communication,14,English,2,Error,1,Ethical Hacking,2,Ethical_Hacking,1,ETL_Tools,17,Exam Dumps,1,Exam Preparation,13,Exam_Cracker,3,Exams,5,Exams_Banking,1,Exams_Prep,1,Excel,22,Excel_Macros,22,Excel_Terms,1,Excel_VBA,22,File System,1,Free_OS,1,Free_Softwares,1,Games,3,GATE,20,GATE EC,1,GATE Electronics & Communication,1,GATE_2019,16,GATE_2020,16,GATE_2021,7,GATE_EC,10,GATE_ECE,9,GATE_ECE_Best_Book,1,GATE_Electrical,1,GATE_Electronics,12,GATE_Made_Easy,1,GATE_ME,6,GATE_Mechanical,6,GGSIPU,1,Google,1,Google Cloud,2,Google News,2,Government Jobs,2,Graphic,1,GRUB,1,Handwritten_Notes,10,Hardware,6,HCL_Prep,1,HDFS,1,Hive,1,Hive Tutorials,1,Hosting,2,How To,15,How_To,8,HR Interview,2,HR Interview Questions,1,HR_Interview,3,Hyderabad_News,1,IBPS,2,IBPS_English,1,IBPS_PO,2,Indian History,5,Informatica,1,Informatica_Interview,1,Information,20,Internet,5,Interview,20,Interview Preparation,5,Interview_Prep,20,IPU,1,ISRO Jobs,1,IT Jobs,4,IT News,1,Java,2,Java Interview,1,Java_Interview,2,Java_Questions_&_answers,1,JavaScript,1,JEE,6,JEE_Mains,6,Job Alert,6,Jobs,1,Kali Linux,1,Kali Linux Tools,1,Katoolin,1,Keyboard,1,Keyboard_Shortcuts,1,Learn_VBA,22,Linux,42,Linux Command,1,Linux Interview,1,Linux Mint,1,Linux Tools,4,Linux Tutorials,1,Linux_Distributions,1,Linux_Interview,1,Linux_Redirections,1,Linux_Scripting,30,Linux_Shell_Arrays,1,Linux_Shell_Functions,1,Linux_Shell_Quote,1,Linux_Signals_And_Traps,1,Logical_Reasoning,1,M.Tech Jobs,1,Machine Learning,1,Machine Learning Interview,1,Machine_Learning,1,Machine_Learning_Interview,1,Macros,22,Manufacturing_Processes,1,ME_1st_Semester,1,ME_Fluid_Mechanics,1,ME_Industrial_Engineering,1,ME_Machine_Design,1,Mechanical,6,Memory,1,Microcontroller,1,Microsoft,5,Microsoft Azure Associate,1,Microsoft Azure Fundamentals,3,Microsoft_Azure,1,Microsoft_Azure_Interview,1,Mobile,1,Mobile News,1,MS_Access,40,MySQL,44,NCERT Solutions,63,Network,2,News,3,Notes,31,OOPs,1,Open_Source_OS,1,OpenTelemetry,1,Operating_Systems,2,Operating_Systems_Interview,1,Oracle,42,Oracle Interview,1,Oracle_Interview,1,Paytm Jobs,1,Physics,2,PL_SQL,42,PL_SQL_Interview,1,Placement,21,Placement Preparation,18,Placement_Prep,24,Poetry,1,Programming,28,Programming_Languages,1,Python,28,Python_Built_In_Strings_Methods,2,Python_built_In_Tuple_Functions,1,Python_CAlling_a_Function,1,Python_CGI,1,Python_Class,1,Python_Data_Types,1,Python_DAte,1,Python_Decision_Making,1,Python_Dictionary,1,Python_DOM_APIs,1,Python_Features,1,Python_Files_Functions,1,Python_For_Loop,1,Python_Functions,6,Python_GUI,1,Python_History,1,Python_If_Else,1,Python_import_Statements,1,Python_Installation,1,Python_Interview,1,Python_JPython,1,Python_Lists,2,Python_Loops,1,Python_Methods,1,Python_Modules,1,Python_MySQL,1,Python_Nested_If_Else,1,Python_Nested_Loops,1,Python_Number_Type_Conversion,1,Python_Numbers,2,Python_Object_Oriented,1,Python_OOP,1,Python_Pass_By_Reference_vs_Value,1,Python_Programming,28,Python_Scripting,28,Python_Special_Operators,1,Python_Strings,2,Python_Strings_Functions,1,Python_Threading_Module,1,Python_Time,1,Python_Tkinter,1,Python_Tuples,2,Python_Tutorial,28,Python_Types_of_Loops,1,Python_Variables,1,Python_Web_Server,1,Python_While_Loop,1,Python_wxPython,1,Python_XML_Processing,1,PythonPath_Setup,1,Quantitative,1,Quantitative_Aptitude,2,RDBMS,1,Run,1,S3,1,Sabrent,1,Samsung,1,SBI Jobs,1,Scripting,52,Scripting Interview,1,Security,1,Server,2,service now,1,Shell_Command_Manual,1,Shell_Logging_Commands,1,Shell_Scripting,31,Shell_Scripting_Interview,1,Software Engineering Interview,1,Software_Engineering_Interview,1,Solutions,1,Spinnaker,1,SQL,46,SQL Interview,1,SQL_Alias_Syntax,1,SQL_Alter_Table_Query,1,SQL_Alter_Table_Statement,1,SQL_AND_OR_Query,1,SQL_AND_OR_Statement,1,SQL_Architecture,1,SQL_Clone_Table,1,SQL_Commands,1,SQL_Conjunctive_Operators,1,SQL_Constraints,1,SQL_Create_Database,1,SQL_Create_Table,1,SQL_DataTypes,1,SQL_Date_Functions,1,SQL_Date_Statement,1,SQL_DCL,1,SQL_Server,39,SQL_Temporary_Table_Statement,1,SQLite,43,Sqoop,9,Sqoop_Tutorial,10,SSC,4,SSC CGL,1,SSC CHSL,1,SSC_CGL,3,SSC_CGL_English,1,SSC_CHSL,1,SSC_CPO,1,SSC_GS,1,SSC_Quantative,1,SSD,1,ssl,1,Storage,1,Talend,17,Talend Interview,1,Talend_ETL,15,Talend_Tutorials,16,TCS Interview,1,TCS Jobs,1,TCS News,1,TCS_Interview,1,TCS_Prep,1,Tech News,15,Tech Tips,18,Teradata_Interview,1,Terraform,2,Tips & Tricks,12,Tips_&_Tricks,18,Top 10,3,Top 50,10,Top_10,1,Top_50,18,Top25,1,Tutorials,165,Tutorials_Python,28,Tutorials_VBA,11,Unix,32,Unix Interview,1,Unix Tutorials,1,Unix_Interview,1,Unix_Scripting,31,UPSC,5,VBA,22,VBA_Basics,22,VBA_Excel,22,VBA_Scripting,22,VBA_Tutorials,22,VirtualBox,1,Visual_Basic_Application,22,VPN,1,Websites,3,Windows,22,WordPress,2,Yarn,1,
ltr
item
Shout4Education - Get Jobs, Tutorials and Notes: VBA - Date-Time Function
VBA - Date-Time Function
VBA - Date-Time Function - VBA Tutorials ... Best VBA Tutorials only @ Shout4Education ... Learn VBA in an Easy and Simplified Way ... Keep Shouting For Education and Keep Learning ... VBScript Date and Time Functions help the developers to convert date and time from one format to another or to express the date or time value in the format that suits a specific condition. Date Functions Sr.No. Function & Description 1 Date A Function, which returns the current system date. 2 CDate A Function, which converts a given input to date. 3 DateAdd A Function, which returns a date to which a specified time interval has been added. 4 DateDiff A Function, which returns the difference between two time period. 5 DatePart A Function, which returns a specified part of the given input date value. 6 DateSerial A Function, which returns a valid date for the given year, month, and date. 7 FormatDateTime A Function, which formats the date based on the supplied parameters. 8 IsDate A Function, which returns a Boolean Value whether or not the supplied parameter is a date. 9 Day A Function, which returns an integer between 1 and 31 that represents the day of the specified date. 10 Month A Function, which returns an integer between 1 and 12 that represents the month of the specified date. 11 Year A Function, which returns an integer that represents the year of the specified date. 12 MonthName A Function, which returns the name of the particular month for the specified date. 13 WeekDay A Function, which returns an integer(1 to 7) that represents the day of the week for the specified day. 14 WeekDayName A Function, which returns the weekday name for the specified day. VBA - Date Function The Function returns the current system date. Syntax date() Example Add a button and add the following function. Private Sub Constant_demo_Click() Dim a as Variant a = date() msgbox "The Value of a : " & a End Sub When you execute the function, it produces the following output. The Value of a : 08/04/2020 VBA - CDate Function The Function converts a valid date and time expression to type date. Syntax cdate(date) Example Add a button and add the following function. Private Sub Constant_demo_Click() Dim a as Variant Dim b as Variant a = cdate("Jan 01 2020") msgbox("The Value of a : " & a) b = cdate("31 Dec 2050") msgbox("The Value of b : " & b) End Sub When you execute the function, it produces the following output. The Value of a : 1/01/2020 The Value of b : 31/12/2050 VBA - DateAdd Function A Function, which returns a date to which a specified time interval has been added. Syntax DateAdd(interval,number,date) Parameter Description Interval − A required parameter. It can take the following values. d - day of the year m - month of the year y - year of the year yyyy - year w - weekday ww - week q - quarter h - hour m - minute s - second Number − A required parameter. It can take both positive and negative parameters. Date − A required parameter. A variant or literal representing the date to which an interval is added. Example Private Sub Constant_demo_Click() ' Positive Interal date1 = 27-Jun-1894 msgbox("Line 1 : " &DateAdd("yyyy",1,date1)) msgbox("Line 2 : " &DateAdd("q",1,date1)) msgbox("Line 3 : " &DateAdd("m",1,date1)) msgbox("Line 4 : " &DateAdd("y",1,date1)) msgbox("Line 5 : " &DateAdd("d",1,date1)) msgbox("Line 6 : " &DateAdd("w",1,date1)) msgbox("Line 7 : " &DateAdd("ww",1,date1)) msgbox("Line 8 : " &DateAdd("h",1,"01-Jan-2013 12:00:00")) msgbox("Line 9 : " &DateAdd("n",1,"01-Jan-2013 12:00:00")) msgbox("Line 10 : "&DateAdd("s",1,"01-Jan-2013 12:00:00")) ' Negative Interval msgbox("Line 11 : " &DateAdd("yyyy",-1,date1)) msgbox("Line 12 : " &DateAdd("q",-1,date1)) msgbox("Line 13 : " &DateAdd("m",-1,date1)) msgbox("Line 14 : " &DateAdd("y",-1,date1)) msgbox("Line 15 : " &DateAdd("d",-1,date1)) msgbox("Line 16 : " &DateAdd("w",-1,date1)) msgbox("Line 17 : " &DateAdd("ww",-1,date1)) msgbox("Line 18 : " &DateAdd("h",-1,"01-Jan-2013 12:00:00")) msgbox("Line 19 : " &DateAdd("n",-1,"01-Jan-2013 12:00:00")) msgbox("Line 20 : " &DateAdd("s",-1,"01-Jan-2013 12:00:00")) End Sub When you execute the above function, it produces the following output. Line 1 : 27/06/1895 Line 2 : 27/09/1894 Line 3 : 27/07/1894 Line 4 : 28/06/1894 Line 5 : 28/06/1894 Line 6 : 28/06/1894 Line 7 : 4/07/1894 Line 8 : 1/01/2013 1:00:00 PM Line 9 : 1/01/2013 12:01:00 PM Line 10 : 1/01/2013 12:00:01 PM Line 11 : 27/06/1893 Line 12 : 27/03/1894 Line 13 : 27/05/1894 Line 14 : 26/06/1894 Line 15 : 26/06/1894 Line 16 : 26/06/1894 Line 17 : 20/06/1894 Line 18 : 1/01/2013 11:00:00 AM Line 19 : 1/01/2013 11:59:00 AM Line 20 : 1/01/2013 11:59:59 AM VBA - DateDiff Function A Function, which returns the difference between two specified time intervals. Syntax DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]]) Parameter Description Interval − A required parameter. It can take the following values. d - day of the year m - month of the year y - year of the year yyyy - year w - weekday ww - week q - quarter h - hour m - minute s - second Date1 and Date2 − Required parameters. Firstdayofweek − An optional parameter. Specifies the first day of the week. It can take the following values. 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting 1 = vbSunday - Sunday 2 = vbMonday - Monday 3 = vbTuesday - Tuesday 4 = vbWednesday - Wednesday 5 = vbThursday - Thursday 6 = vbFriday - Friday 7 = vbSaturday - Saturday Firstdayofyear − An optional parameter. Specifies the first day of the year. It can take the following values. 0 = vbUseSystem - Use National Language Support (NLS) API setting 1 = vbFirstJan1 - Start with the week in which January 1 occurs (default) 2 = vbFirstFourDays - Start with the week that has at least four days in the new year 3 = vbFirstFullWeek - Start with the first full week of the new year Example Add a button and add the following function. Private Sub Constant_demo_Click() Dim fromDate as Variant fromDate = "01-Jan-09 00:00:00" Dim toDate as Variant toDate = "01-Jan-10 23:59:00" msgbox("Line 1 : " &DateDiff("yyyy",fromDate,toDate)) msgbox("Line 2 : " &DateDiff("q",fromDate,toDate)) msgbox("Line 3 : " &DateDiff("m",fromDate,toDate)) msgbox("Line 4 : " &DateDiff("y",fromDate,toDate)) msgbox("Line 5 : " &DateDiff("d",fromDate,toDate)) msgbox("Line 6 : " &DateDiff("w",fromDate,toDate)) msgbox("Line 7 : " &DateDiff("ww",fromDate,toDate)) msgbox("Line 8 : " &DateDiff("h",fromDate,toDate)) msgbox("Line 9 : " &DateDiff("n",fromDate,toDate)) msgbox("Line 10 : "&DateDiff("s",fromDate,toDate)) End Sub When you execute the above function, it produces the following output. Line 1 : 1 Line 2 : 4 Line 3 : 12 Line 4 : 365 Line 5 : 365 Line 6 : 52 Line 7 : 52 Line 8 : 8783 Line 9 : 527039 Line 10 : 31622340 VBA - DatePart Function A Function, which returns the specific part of the given date. Syntax DatePart(interval,date[,firstdayofweek[,firstweekofyear]]) Parameter Description Interval − A required parameter. It can take the following values. d - day of the year. m - month of the year y - year of the year yyyy - year w - weekday ww - week q - quarter h - hour n - minute s - second Date1 − A required parameter. Firstdayofweek − An optional parameter. Specifies the first day of the week. It can take the following values. 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting 1 = vbSunday - Sunday 2 = vbMonday - Monday 3 = vbTuesday - Tuesday 4 = vbWednesday - Wednesday 5 = vbThursday - Thursday 6 = vbFriday - Friday 7 = vbSaturday - Saturday Firstdayofyear − An optional parameter. Specifies the first day of the year. It can take the following values. 0 = vbUseSystem - Use National Language Support (NLS) API setting 1 = vbFirstJan1 - Start with the week in which January 1 occurs (default) 2 = vbFirstFourDays - Start with the week that has at least four days in the new year 3 = vbFirstFullWeek - Start with the first full week of the new year Example Add a button and add the following function. Private Sub Constant_demo_Click() Dim Quarter as Variant Dim DayOfYear as Variant Dim WeekOfYear as Variant Date1 = "2013-01-15" Quarter = DatePart("q", Date1) msgbox("Line 1 : " & Quarter) DayOfYear = DatePart("y", Date1) msgbox("Line 2 : " & DayOfYear) WeekOfYear = DatePart("ww", Date1) msgbox("Line 3 : " & WeekOfYear) msgbox("Line 4 : " & DatePart("m",Date1)) End Sub When you execute the above function, it produces the following output. Line 1 : 1 Line 2 : 15 Line 3 : 3 Line 4 : 1 VBA - DateSerial Function A Function, which returns a date for the specified day, month, and year parameters. Syntax DateSerial(year,month,day) Parameter Description Year − A required parameter. A number between 100 and 9999 or a numeric expression. Values between 0 and 99 are interpreted as the years 1900 to 1999. For all other year arguments, use a complete four-digit year. Month − A required parameter. It can also be in the form of an expression, which should range from 1 to 12. Day − A required parameter. It can also be in the form of an expression, which should range from 1 to 31. Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox(DateSerial(2013,5,10)) End Sub When you execute the above function, it produces the following output. 10/05/2014 VBA - Format DateTime Function A Function, which helps the developers to format and return a valid date and time expression. Syntax FormatDateTime(date,format) Parameter Description Date − A required parameter. Format − An optional parameter. The Value that specifies the date or time format to be used. It can take the following values. 0 = vbGeneralDate - Default 1 = vbLongDate - Returns date 2 = vbShortDate - Returns date 3 = vbLongTime - Returns time 4 = vbShortTime - Returns time Example Add a button and add the following function. Private Sub Constant_demo_Click() d = ("2013-08-15 20:25") msgbox("Line 1 : " & FormatDateTime(d)) msgbox("Line 2 : " & FormatDateTime(d,1)) msgbox("Line 3 : " & FormatDateTime(d,2)) msgbox("Line 4 : " & FormatDateTime(d,3)) msgbox("Line 5 : " & FormatDateTime(d,4)) End Sub When you execute the above function, it produces the following output. Line 1 : 15/08/2013 8:25:00 PM Line 2 : Thursday, 15 August 2013 Line 3 : 15/08/2013 Line 4 : 8:25:00 PM Line 5 : 20:25 VBA - IsDate Function A Function, which returns a Boolean value whether or not the given input is a date. Syntax IsDate(expression) Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox("Line 1 : " & IsDate("Nov 03, 1950")) msgbox("Line 2 : " & IsDate(#01/31/20#)) msgbox("Line 3 : " & IsDate(#05/31/20 10:30 PM#)) End Sub When you execute the above function, it produces the following output. Line 1 : True Line 2 : True Line 3 : True VBA - Day Function The Day function returns a number between 1 and 31 that represents the day of the specified date. Syntax Day(date) Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox(Day("2013-06-30")) End Sub When you execute the above function, it produces the following output. 30 VBA - Month Function The Month function returns a number between 1 and 12 that represents the month of the specified date. Syntax Month(date) Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox(Month("2013-06-30")) End Sub When you execute the above function, it produces the following output. 6 VBA - Year Function The Year function returns an integer that represents a year of the specified date. Syntax Year(date) Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox(Year("2013-06-30")) End sub When you execute the above function, it produces the following output. 2013 VBA - Month Name The MonthName function returns the name of the month for the specified date. Syntax MonthName(month[,toabbreviate]) Parameter Description Month − A required parameter. It specifies the number of the month. Toabbreviate − An optional parameter. A Boolean value that indicates if the month name is to be abbreviated. If left blank, the default value would be taken as False. Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox("Line 1 : " & MonthName(01,True)) msgbox("Line 2 : " & MonthName(01,false)) msgbox("Line 3 : " & MonthName(07,True)) msgbox("Line 4 : " & MonthName(07,false)) End Sub When you execute the above function, it produces the following output. Line 1 : Jan Line 2 : January Line 3 : Jul Line 4 : July VBA - WeekDay The WeekDay function returns an integer from 1 to 7 that represents the day of the week for the specified date. Syntax Weekday(date[,firstdayofweek]) Parameter Description Date − A required parameter. The weekday will return a specified date. Firstdayofweek − An optional parameter. Specifies the first day of the week. It can take the following values. 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting 1 = vbSunday - Sunday 2 = vbMonday - Monday 3 = vbTuesday - Tuesday 4 = vbWednesday - Wednesday 5 = vbThursday - Thursday 6 = vbFriday - Friday 7 = vbSaturday - Saturday Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox("Line 1: " & Weekday("2013-05-16",1)) msgbox("Line 2: " & Weekday("2013-05-16",2)) msgbox("Line 3: " & Weekday("2013-05-16",2)) msgbox("Line 4: " & Weekday("2010-02-16")) msgbox("Line 5: " & Weekday("2010-02-17")) msgbox("Line 6: " & Weekday("2010-02-18")) End Sub When you execute the above function, it produces the following output. Line 1: 5 Line 2: 4 Line 3: 4 Line 4: 3 Line 5: 4 Line 6: 5 VBA - WeekDay Name The WeekDayName function returns the name of the weekday for the specified day. Syntax WeekdayName(weekday[,abbreviate[,firstdayofweek]]) Parameter Description Weekday − A required parameter. The number of the weekday. Toabbreviate − An optional parameter. A Boolean value that indicates if the month name is to be abbreviated. If left blank, the default value would be taken as False. Firstdayofweek − An optional parameter. Specifies the first day of the week. 0 = vbUseSystemDayOfWeek - Use National Language Support (NLS) API setting 1 = vbSunday - Sunday 2 = vbMonday - Monday 3 = vbTuesday - Tuesday 4 = vbWednesday - Wednesday 5 = vbThursday - Thursday 6 = vbFriday - Friday 7 = vbSaturday - Saturday Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox("Line 1 : " &WeekdayName(3)) msgbox("Line 2 : " &WeekdayName(2,True)) msgbox("Line 3 : " &WeekdayName(1,False)) msgbox("Line 4 : " &WeekdayName(2,True,0)) msgbox("Line 5 : " &WeekdayName(1,False,1)) End Sub When you execute the above function, it produces the following output. Line 1 : Tuesday Line 2 : Mon Line 3 : Sunday Line 4 : Tue Line 5 : Sunday Time Functions Sr.No. Function & Description 1 Now A Function, which returns the current system date and time. 2 Hour A Function, which returns an integer between 0 and 23 that represents the hour part of the given time. 3 Minute A Function, which returns an integer between 0 and 59 that represents the minutes part of the given time. 4 Second A Function, which returns an integer between 0 and 59 that represents the seconds part of the given time. 5 Time A Function, which returns the current system time. 6 Timer A Function, which returns the number of seconds and milliseconds since 12:00 AM. 7 TimeSerial A Function, which returns the time for the specific input of hour, minute and second. 8 TimeValue A Function, which converts the input string to a time format. VBA - Now Function The Function Now returns the current system date and time. Syntax Now() Example Add a button and add the following function. Private Sub Constant_demo_Click() Dim a as Variant a = Now() msgbox("The Value of a : " & a) End Sub When you execute the above function, it produces the following output. The Value of a : 19/07/2013 3:04:09 PM VBA - Hour Function The Hour Function returns a number between 0 and 23 that represents the hour of the day for the specified time stamp. Syntax Hour(time) Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox("Line 1: " & Hour("3:13:45 PM")) msgbox("Line 2: " & Hour("23:13:45")) msgbox("Line 3: " & Hour("2:20 PM")) End Sub When you execute the above function, it produces the following output. Line 1: 15 Line 2: 23 Line 3: 14 VBA - Minute Function The Minute Function returns a number between 0 and 59 that represents the minute of the hour for the specified time stamp. Syntax Minute(time) Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox("Line 1: " & Minute("3:13:45 PM")) msgbox("Line 2: " & Minute("23:43:45")) msgbox("Line 3: " & Minute("2:20 PM")) End Sub When you execute the above function, it produces the following output. Line 1: 13 Line 2: 43 Line 3: 20 VBA - Second Function The Second Function returns a number between 0 and 59 that represents the second of the hour for the specified time stamp. Syntax Second(time) Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox("Line 1: " & Second("3:13:25 PM")) msgbox("Line 2: " & Second("23:13:45")) msgbox("Line 3: " & Second("2:20 PM")) End Sub When you execute the above function, it produces the following output. Line 1: 25 Line 2: 45 Line 3: 0 VBA - Time Function The Time Function returns the current system time. Syntax Time() Example Private Sub Constant_demo_Click() msgbox("Line 1: " & Time()) End Sub When you execute the above function, it produces the following output. Line 1: 3:29:15 PM VBA - Timer Function The Timer Function returns the number of seconds and milliseconds since 12:00 AM. Syntax Timer() Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox("Time is : " & Now()) msgbox("Timer is: " & Timer()) End Sub When you execute the above function, it produces the following output. Time is : 19/07/2013 3:45:53 PM Timer is: 56753.4 VBA - Time Serial Function The TimeSerial function returns the time for the specified hour, minute, and second values. Syntax TimeSerial(hour,minute,second) Parameter Description Hour − A required parameter, which is an integer between 0 and 23 or any numeric expression. Minute − A required parameter, which is an integer between 0 and 59 or any numeric expression. Second − A required parameter, which is an integer between 0 and 59 or any numeric expression. Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox(TimeSerial(20,1,2)) msgbox(TimeSerial(0,59,59)) msgbox(TimeSerial(7*2,60/3,15+3)) End Sub When you execute the above function, it produces the following output. 8:01:02 PM 12:59:59 AM 2:20:18 PM VBA - Time Value Function The TimeValue Function converts the given input string to a valid time. Syntax TimeValue(StringTime) Example Add a button and add the following function. Private Sub Constant_demo_Click() msgbox(TimeValue("20:30")) msgbox(TimeValue("5:15")) msgbox(TimeValue("2:30:58")) End Sub When you execute the above function, it produces the following output. 8:30:00 PM 5:15:00 AM 2:30:58 AM @ Shout 4 Education , @ Shout For Education
https://1.bp.blogspot.com/-6xBCiWeXIsc/XoZMSCtu_6I/AAAAAAAAA40/L-2muAnBbkEdiOgs7Ja3hJoFd8-3ofuuQCPcBGAYYCw/s640/VBA_Tutorials_Shout4Education.jpg
https://1.bp.blogspot.com/-6xBCiWeXIsc/XoZMSCtu_6I/AAAAAAAAA40/L-2muAnBbkEdiOgs7Ja3hJoFd8-3ofuuQCPcBGAYYCw/s72-c/VBA_Tutorials_Shout4Education.jpg
Shout4Education - Get Jobs, Tutorials and Notes
https://www.shout4education.com/2020/04/vba-date-time-function.html
https://www.shout4education.com/
https://www.shout4education.com/
https://www.shout4education.com/2020/04/vba-date-time-function.html
true
7947974353386595563
UTF-8
Loaded All Posts Not Found Any Posts :( View All Read More Reply Cancel Reply Delete By Home Pages Posts View All Similar Posts Label Archive Search All Posts Not Found Any Post Match with Your Request Sorry !! Search Something Blazing :) Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Just Now 1 Minute Ago $$1$$ minutes ago 1 Hour Ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago More than 5 Weeks Ago Followers Follow :) This Premium Content is LOCKED !!! STEP 1: Share. STEP 2: Click the Link You Shared to Unlock Copy All Code Select All Code All Codes were Copied to Your Clipboard :) Can NOT Copy the Codes / Texts, Please Press [CTRL]+[C] (or CMD+C with Mac) to Copy