Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:01,792 --> 00:00:05,120
Extract function will help us extract parts
1
2
00:00:05,376 --> 00:00:06,912
from a date or a time
2
3
00:00:07,680 --> 00:00:09,216
so if you have a timestamp
3
4
00:00:09,472 --> 00:00:14,080
Extract can help you get any part of that timestamp out
4
5
00:00:14,592 --> 00:00:15,104
So
5
6
00:00:15,872 --> 00:00:21,248
this is the index. You write extract then you specify a unit which you want from the date
6
7
00:00:21,504 --> 00:00:23,808
So you will have to use this keyword from
7
8
00:00:24,320 --> 00:00:25,600
When you are using extract
8
9
00:00:25,856 --> 00:00:27,648
What are the different types of units
9
10
00:00:28,160 --> 00:00:30,464
Majorly these are the types of units used
10
11
00:00:30,720 --> 00:00:32,256
There are Other units also
11
12
00:00:32,512 --> 00:00:34,816
But these are the most commonly used ones
12
13
00:00:35,328 --> 00:00:36,864
If you want to find out
13
14
00:00:37,120 --> 00:00:38,912
Which day of the month it is
14
15
00:00:40,448 --> 00:00:43,520
From the given date you can use the day unit
15
16
00:00:44,544 --> 00:00:46,848
If you want to find out
16
17
00:00:48,128 --> 00:00:50,176
The number of seconds since
17
18
00:00:50,944 --> 00:00:52,992
1st Jan 1970
18
19
00:00:53,760 --> 00:00:59,136
Epoch function is used. We will see why this epoch function is important in the example
19
20
00:01:00,416 --> 00:01:03,232
If you want to find out the hour part only
20
21
00:01:03,488 --> 00:01:04,768
Of that timestamp
21
22
00:01:05,024 --> 00:01:11,168
You can use hour. if you want minutes you can use minute if you want month second year and so on
22
23
00:01:11,680 --> 00:01:12,960
Let us see an example
23
24
00:01:14,496 --> 00:01:17,568
If you want to take out the day
24
25
00:01:18,336 --> 00:01:19,616
From this date
25
26
00:01:20,640 --> 00:01:21,664
So it'll give you
26
27
00:01:21,920 --> 00:01:25,504
It is the 25th day of the month so you'll have to mention
27
28
00:01:25,760 --> 00:01:27,552
Day from the date
28
29
00:01:28,064 --> 00:01:31,392
Day from the timestamp of any date
29
30
00:01:31,904 --> 00:01:35,232
If you want minutes you'd write minute from the time
30
31
00:01:37,536 --> 00:01:40,096
Now if you remember in our sales table
31
32
00:01:40,608 --> 00:01:42,144
We had ship date and order date
32
33
00:01:43,424 --> 00:01:44,704
When we did age
33
34
00:01:44,960 --> 00:01:48,032
We received a string with said
34
35
00:01:48,288 --> 00:01:54,432
so many days were taken. you cannot do mathematical operations on that string says it is a
35
36
00:01:54,688 --> 00:01:55,200
String
36
37
00:01:55,456 --> 00:01:58,272
If you want difference between the two dates
37
38
00:01:58,528 --> 00:02:04,672
As number of seconds number of hours or number of days so that you can further work on that number
38
39
00:02:05,184 --> 00:02:07,488
This extract function will help you get that
39
40
00:02:08,512 --> 00:02:11,584
So when we select order line and extract
40
41
00:02:12,352 --> 00:02:13,632
epoch from
41
42
00:02:13,888 --> 00:02:15,424
Ship date minus order date
42
43
00:02:15,680 --> 00:02:21,824
What will this give me. ship date - order date will give me the difference of these two dates
43
44
00:02:22,592 --> 00:02:23,104
If I
44
45
00:02:24,128 --> 00:02:28,736
do epoch now on this date I'll get the difference
45
46
00:02:28,992 --> 00:02:31,808
Between these two dates in seconds
46
47
00:02:32,576 --> 00:02:36,416
When I have the seconds I can convert those seconds into minutes
47
48
00:02:37,184 --> 00:02:39,488
I can Convert those minutes into
48
49
00:02:39,744 --> 00:02:45,632
hours by dividing by 60. i can convert those hours into days by dividing by 24
49
50
00:02:46,400 --> 00:02:47,680
So that number
50
51
00:02:47,936 --> 00:02:49,984
Of seconds can be used
51
52
00:02:50,240 --> 00:02:52,288
To do any type of mathematical
52
53
00:02:52,544 --> 00:02:58,688
Function. once you have the number of days you can then use the comparison operator to find out which
53
54
00:02:58,944 --> 00:03:01,504
Order took more than 2 days more than 3 days
54
55
00:03:01,760 --> 00:03:06,368
Those kind of things you cannot do on a string type of output
55
56
00:03:07,136 --> 00:03:08,160
So let us go
56
57
00:03:08,416 --> 00:03:09,952
And run these queries
57
58
00:03:14,048 --> 00:03:15,328
So let us find out
58
59
00:03:15,584 --> 00:03:16,096
the
59
60
00:03:16,352 --> 00:03:16,864
day
60
61
00:03:20,192 --> 00:03:23,008
For the current date. so we will select
61
62
00:03:23,264 --> 00:03:24,288
Extract
62
63
00:03:24,544 --> 00:03:27,872
Day from
63
64
00:03:28,128 --> 00:03:29,920
The current
64
65
00:03:30,432 --> 00:03:31,456
Date
65
66
00:03:36,832 --> 00:03:37,856
Let us run this query
66
67
00:03:38,112 --> 00:03:39,904
And we will see it is the
67
68
00:03:40,160 --> 00:03:42,208
27th day of the month
68
69
00:03:44,768 --> 00:03:48,096
Similarly if you want to extract the hour
69
70
00:03:48,352 --> 00:03:49,120
Of this
70
71
00:03:49,376 --> 00:03:50,912
day
71
72
00:03:51,424 --> 00:03:57,568
We will select current timestamp
72
73
00:03:59,616 --> 00:04:00,896
And extract
73
74
00:04:01,920 --> 00:04:03,456
hour from the
74
75
00:04:05,248 --> 00:04:07,040
Current timestamp
75
76
00:04:07,296 --> 00:04:11,392
So that we can compare that both are giving us
76
77
00:04:11,904 --> 00:04:13,440
The same answer
77
78
00:04:15,232 --> 00:04:16,256
So it is the
78
79
00:04:16,512 --> 00:04:18,815
14th hour of this day
79
80
00:04:19,583 --> 00:04:20,351
That is what
80
81
00:04:20,863 --> 00:04:21,375
hour
81
82
00:04:21,631 --> 00:04:23,679
Extracted from the timestamp is giving us
82
83
00:04:25,983 --> 00:04:30,847
Now let us find out the difference between two dates in seconds
83
84
00:04:31,359 --> 00:04:33,151
For that we will be using the epoch function
84
85
00:04:33,663 --> 00:04:35,199
Let us write select
85
86
00:04:37,503 --> 00:04:40,319
order date
86
87
00:04:42,111 --> 00:04:43,391
Ship date
87
88
00:04:44,671 --> 00:04:45,951
And
88
89
00:04:48,767 --> 00:04:49,791
extract
89
90
00:04:51,583 --> 00:04:57,727
Epoch from then within this we will
90
91
00:04:57,983 --> 00:05:01,567
Mention the difference of these two dates
91
92
00:05:01,823 --> 00:05:03,103
So ship date minus
92
93
00:05:04,895 --> 00:05:08,735
Order date
93
94
00:05:10,527 --> 00:05:11,551
From
94
95
00:05:12,319 --> 00:05:18,463
Sales table
95
96
00:05:18,719 --> 00:05:21,791
Let us run this
96
97
00:05:22,559 --> 00:05:24,095
So this is giving an error
97
98
00:05:24,607 --> 00:05:25,887
Because when
98
99
00:05:26,143 --> 00:05:28,959
We subtracted ship date minus order date
99
100
00:05:29,471 --> 00:05:31,263
It gave an output of integer
100
101
00:05:31,519 --> 00:05:35,103
And when we are finding epoch of this integer
101
102
00:05:35,359 --> 00:05:37,663
It is giving an error it should be a date
102
103
00:05:38,687 --> 00:05:40,479
So let us rectify this
103
104
00:05:41,503 --> 00:05:47,647
We will do epoch from ship date and then minus epoch from order date
104
105
00:05:47,903 --> 00:05:52,511
Let us write select order date
105
106
00:05:53,023 --> 00:05:54,815
comma ship date comma
106
107
00:05:57,887 --> 00:06:01,727
Extract
107
108
00:06:04,031 --> 00:06:05,823
Epoch from ship date
108
109
00:06:10,175 --> 00:06:15,039
minus extract
109
110
00:06:15,295 --> 00:06:20,415
epoch from
110
111
00:06:20,927 --> 00:06:25,023
Order date
111
112
00:06:29,375 --> 00:06:32,191
This whole thing I want in one column
112
113
00:06:33,727 --> 00:06:35,775
From the table sales
113
114
00:06:39,359 --> 00:06:41,407
Let us name this as
114
115
00:06:43,967 --> 00:06:44,991
Seconds taken
115
116
00:06:45,503 --> 00:06:48,063
sec taken
116
117
00:06:48,319 --> 00:06:51,135
From
117
118
00:06:51,391 --> 00:06:52,671
Sales table
118
119
00:06:57,023 --> 00:06:59,071
when we run this
119
120
00:06:59,583 --> 00:07:02,143
When order date was
120
121
00:07:02,399 --> 00:07:08,543
8th November 2016 and ship date was 11th November 2016 there the difference of 3 days
121
122
00:07:10,335 --> 00:07:16,479
3 days into 24 hours into 60 minutes into 60 seconds will give us this many
122
123
00:07:16,735 --> 00:07:17,247
Seconds
123
124
00:07:18,015 --> 00:07:23,903
If you had exact timestamp in the order date and exact timestamp in the ship date
124
125
00:07:24,159 --> 00:07:26,207
You will get the exact seconds
125
126
00:07:26,463 --> 00:07:27,743
Between these two
126
127
00:07:27,999 --> 00:07:29,791
timestamps
127
128
00:07:30,047 --> 00:07:31,583
Now that we have the seconds
128
129
00:07:32,095 --> 00:07:36,447
You can convert this seconds into minutes into hours into days
129
130
00:07:36,959 --> 00:07:40,287
By dividing it by 60 60 24 and so on
130
131
00:07:41,055 --> 00:07:44,383
And you can then order it by numeric value
131
132
00:07:45,151 --> 00:07:47,455
You can also put operators
132
133
00:07:47,967 --> 00:07:49,759
Say if you have it in days
133
134
00:07:50,015 --> 00:07:51,295
So if you want to find out
134
135
00:07:51,551 --> 00:07:54,879
for which orders you took more than 3 days
135
136
00:07:55,135 --> 00:07:55,903
You can
136
137
00:07:56,159 --> 00:07:57,695
Take out those order separately
137
138
00:07:58,463 --> 00:08:00,511
All those operations can be done
138
139
00:08:00,767 --> 00:08:01,535
Using this
139
140
00:08:02,047 --> 00:08:04,607
Extract operator on the datetime
140
141
00:08:06,399 --> 00:08:09,215
These are all the functions we'll be discussing in datetime
141
142
00:08:09,471 --> 00:08:11,775
And this will majorly cover anything you will be doing in your day-to-day academic or professional life
10523
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.