1
00:00:00,00 --> 00:00:04,400
Hey this is puneet back again and in this 
video we are looking at three date

2
00:00:04,500 --> 00:00:09,300
functions that we can use in vba and that 
can be super useful for you

3
00:00:09,400 --> 00:00:14,200
while working with vba in excel so the first 
function

4
00:00:14,300 --> 00:00:19,100
that we are looking into is FileDateTime 
you can use this function to know that

5
00:00:19,200 --> 00:00:24,000
when a file was last modified on which date 
and in which time

6
00:00:24,100 --> 00:00:28,900
so when you enter the function name you need 
to enter a starting parentheses

7
00:00:29,000 --> 00:00:33,800
and than you need to define the path of that 
particular file so I have this

8
00:00:33,900 --> 00:00:38,700
MP3 file on my desktop so I am gonna get 
the location path of this

9
00:00:38,800 --> 00:00:43,600
file and now I am gonna enter this start

10
00:00:43,700 --> 00:00:48,500
with double quotation marks and than the 
path of the file again double quotaion marks

11
00:00:48,600 --> 00:00:53,400
and than closing the parentheses to get the 
result

12
00:00:53,500 --> 00:00:58,300
out of this function I am gonna put the cell 
A1

13
00:00:58,400 --> 00:01:03,200
now lets run this code so it gives me 3rd 
of October

14
00:01:03,300 --> 00:01:08,100
2021 and afternoon 3:15PM so let me

15
00:01:08,200 --> 00:01:13,000
go the desktop again and check the actual

16
00:01:13,100 --> 00:01:17,900
date and time on modification last modification

17
00:01:18,000 --> 00:01:22,800
so it is 3rd of October 2021

18
00:01:22,900 --> 00:01:27,700
afternoon 3:15PM so the result we are gettting 
with this function is

19
00:01:27,800 --> 00:01:32,600
correct so the point is you can get date 
and time of last modification of any file 
that you have

20
00:01:32,700 --> 00:01:37,500
in your system now the second function we 
are looking into is

21
00:01:37,600 --> 00:01:42,400
date function and date function is one of 
the most useful function

22
00:01:42,500 --> 00:01:47,300
that we have in vba library so with date 
function we can get the current date

23
00:01:47,400 --> 00:01:52,200
so lets say if I want to insert the correct 
date into cell A1

24
00:01:52,300 --> 00:01:57,100
I simply need to use the date function and 
there is no

25
00:01:57,200 --> 00:02:02,000
argument that you need to define so simply 
need to

26
00:02:02,100 --> 00:02:06,900
enter date yes thats it

27
00:02:07,000 --> 00:02:11,800
so when I run this code it gives me

28
00:02:11,900 --> 00:02:16,700
current data according to the date that I 
have in my system and insert it

29
00:02:16,800 --> 00:02:21,600
into a cell A1 and if you want to get date 
in a specific format

30
00:02:21,700 --> 00:02:26,500
other than the default format that we have 
in the excel you can use format function 
along with the date function

31
00:02:26,600 --> 00:02:31,400
so it will go something like this format

32
00:02:31,500 --> 00:02:36,300
and than date than you need to define the 
format in which you want

33
00:02:36,400 --> 00:02:41,200
to enter the date into the cell

34
00:02:41,300 --> 00:02:46,100


35
00:02:46,200 --> 00:02:51,000
and now if I run this code so it gives me 
the current date

36
00:02:51,100 --> 00:02:55,900
as per the format that I have specified in 
the format function

37
00:02:56,000 --> 00:03:00,800
all right so the next function that we have 
is DateAdd function and

38
00:03:00,900 --> 00:03:05,700
this function can be super useful for you 
so with the help of this function you can 
add a interval

39
00:03:05,800 --> 00:03:10,600
into a specif date so lets say we have this 
5 October

40
00:03:10,700 --> 00:03:15,500
2021 in cell A2 and if I want to add five 
years in this

41
00:03:15,600 --> 00:03:20,400
date I can use DateAdd function to that and 
in same way I can add months

42
00:03:20,500 --> 00:03:25,300
days or even I can add time like hours minutes 
and seconds

43
00:03:25,400 --> 00:03:30,200
so lets say if I want to add five years into 
this 5_October_2021

44
00:03:30,300 --> 00:03:35,100
so I am gonna use DateAdd

45
00:03:35,200 --> 00:03:40,000
and than I need to define the interval

46
00:03:40,100 --> 00:03:44,900
that I want to add thats the format that 
I need to specify

47
00:03:45,000 --> 00:03:49,800
than I need to define the number that how 
many intervals I want to add

48
00:03:49,900 --> 00:03:54,700
so if I want to add five years I need to 
specify 5 than

49
00:03:54,800 --> 00:03:59,600
date so for this I am gonna use date to get 
the current date

50
00:03:59,700 --> 00:04:04,500
so this is the same function that we have 
learnt earlier so know if I run this code

51
00:04:04,600 --> 00:04:09,400
so it gives me 5_October_2026 so its five 
years into 2021

52
00:04:09,500 --> 00:04:14,300
and in the same way if you want to add months

53
00:04:14,400 --> 00:04:19,200
so here I will use only m

54
00:04:19,300 --> 00:04:24,100
I want to add okk

55
00:04:24,200 --> 00:04:29,000
6 months and if I

56
00:04:29,100 --> 00:04:33,900
run this code it gives me 5th of April 2022

57
00:04:34,000 --> 00:04:38,800
so we are now into October so November December 
January

58
00:04:38,900 --> 00:04:43,700
February March and April 5th of April so 
here we have few strings

59
00:04:43,800 --> 00:04:48,600
to specify interval that you want to add 
into the date so you can use days

60
00:04:48,700 --> 00:04:53,500
hours minutes months even quarters seconds 
weeks and years

61
00:04:53,600 --> 00:04:58,400
all right so thats it for this video I hope 
you found this video useful and make

62
00:04:58,500 --> 00:05:03,300
sure to subscribe to this channel beacuse 
I will be coming out of with lots of cool 
vba tutorials in coming weeks

63
00:05:03,400 --> 00:05:07,900
I will see you next week

