Information

3 Super Useful Date Functions in VBA

Basic shortcuts

Ctrl + SSave subtitles
Ctrl + click
Double click
Edit highlighted caption
TabEdit next caption
Shift + TabEdit previous caption
EscLeave edit mode
Ctrl + SpacePlay / pause video
Ctrl + HomePlay selected caption
Ctrl + EnterSplit caption at cursor position
at current time

Advanced shortcuts

Ctrl + InsertAdd new caption
Ctrl + DeleteDelete selected caption
Ctrl + IEdit currently played segment
Shift + EnterNew line when editing
Ctrl + LeftPlay from -1s
Ctrl + RightPlay from +1s
Alt + LeftShift caption start time -0.1s
Alt + RightShift caption start time +0.1s
Alt + DownShift caption end time -0.1s
Alt + UpShift caption end time +0.1s

Annotation shortcuts

Ctrl + 1Hesitation
Ctrl + 2Speaker noise
Ctrl + 3Background noise
Ctrl + 4Unknown word
Ctrl + 5Wrong segment
Ctrl + 6Crosstalk segment
You are in the read-only mode. Close
00:00.0
00:04.4
Hey this is puneet back again and in this video we are looking at three date
00:04.5
00:09.3
functions that we can use in vba and that can be super useful for you
00:09.4
00:14.2
while working with vba in excel so the first function
00:14.3
00:19.1
that we are looking into is FileDateTime you can use this function to know that
00:19.2
00:24.0
when a file was last modified on which date and in which time
00:24.1
00:28.9
so when you enter the function name you need to enter a starting parentheses
00:29.0
00:33.8
and than you need to define the path of that particular file so I have this
00:33.9
00:38.7
MP3 file on my desktop so I am gonna get the location path of this
00:38.8
00:43.6
file and now I am gonna enter this start
00:43.7
00:48.5
with double quotation marks and than the path of the file again double quotaion marks
00:48.6
00:53.4
and than closing the parentheses to get the result
00:53.5
00:58.3
out of this function I am gonna put the cell A1
00:58.4
01:03.2
now lets run this code so it gives me 3rd of October
01:03.3
01:08.1
2021 and afternoon 3:15PM so let me
01:08.2
01:13.0
go the desktop again and check the actual
01:13.1
01:17.9
date and time on modification last modification
01:18.0
01:22.8
so it is 3rd of October 2021
01:22.9
01:27.7
afternoon 3:15PM so the result we are gettting with this function is
01:27.8
01:32.6
correct so the point is you can get date and time of last modification of any file that you have
01:32.7
01:37.5
in your system now the second function we are looking into is
01:37.6
01:42.4
date function and date function is one of the most useful function
01:42.5
01:47.3
that we have in vba library so with date function we can get the current date
01:47.4
01:52.2
so lets say if I want to insert the correct date into cell A1
01:52.3
01:57.1
I simply need to use the date function and there is no
01:57.2
02:02.0
argument that you need to define so simply need to
02:02.1
02:06.9
enter date yes thats it
02:07.0
02:11.8
so when I run this code it gives me
02:11.9
02:16.7
current data according to the date that I have in my system and insert it
02:16.8
02:21.6
into a cell A1 and if you want to get date in a specific format
02:21.7
02:26.5
other than the default format that we have in the excel you can use format function along with the date function
02:26.6
02:31.4
so it will go something like this format
02:31.5
02:36.3
and than date than you need to define the format in which you want
02:36.4
02:41.2
to enter the date into the cell
02:41.3
02:46.1
02:46.2
02:51.0
and now if I run this code so it gives me the current date
02:51.1
02:55.9
as per the format that I have specified in the format function
02:56.0
03:00.8
all right so the next function that we have is DateAdd function and
03:00.9
03:05.7
this function can be super useful for you so with the help of this function you can add a interval
03:05.8
03:10.6
into a specif date so lets say we have this 5 October
03:10.7
03:15.5
2021 in cell A2 and if I want to add five years in this
03:15.6
03:20.4
date I can use DateAdd function to that and in same way I can add months
03:20.5
03:25.3
days or even I can add time like hours minutes and seconds
03:25.4
03:30.2
so lets say if I want to add five years into this 5_October_2021
03:30.3
03:35.1
so I am gonna use DateAdd
03:35.2
03:40.0
and than I need to define the interval
03:40.1
03:44.9
that I want to add thats the format that I need to specify
03:45.0
03:49.8
than I need to define the number that how many intervals I want to add
03:49.9
03:54.7
so if I want to add five years I need to specify 5 than
03:54.8
03:59.6
date so for this I am gonna use date to get the current date
03:59.7
04:04.5
so this is the same function that we have learnt earlier so know if I run this code
04:04.6
04:09.4
so it gives me 5_October_2026 so its five years into 2021
04:09.5
04:14.3
and in the same way if you want to add months
04:14.4
04:19.2
so here I will use only m
04:19.3
04:24.1
I want to add okk
04:24.2
04:29.0
6 months and if I
04:29.1
04:33.9
run this code it gives me 5th of April 2022
04:34.0
04:38.8
so we are now into October so November December January
04:38.9
04:43.7
February March and April 5th of April so here we have few strings
04:43.8
04:48.6
to specify interval that you want to add into the date so you can use days
04:48.7
04:53.5
hours minutes months even quarters seconds weeks and years
04:53.6
04:58.4
all right so thats it for this video I hope you found this video useful and make
04:58.5
05:03.3
sure to subscribe to this channel beacuse I will be coming out of with lots of cool vba tutorials in coming weeks
05:03.4
05:07.9
I will see you next week