1
00:00:00,360 --> 00:00:00,680
Okay.

2
00:00:00,690 --> 00:00:08,130
The next thing I want to show you is how we could insert somebody or a row into a table where we don't

3
00:00:08,130 --> 00:00:13,080
have to write the current date and the current time, but instead can get the actual current date.

4
00:00:13,080 --> 00:00:15,480
The actual current time dynamically.

5
00:00:15,960 --> 00:00:21,660
Because I mean, even if I knew exactly the time of the day down to the minute, well, the seconds

6
00:00:21,660 --> 00:00:23,810
is going to change by the time I run my query.

7
00:00:23,820 --> 00:00:29,460
So if I want to do something based off of the current date or time or date time, we have a couple of

8
00:00:29,460 --> 00:00:31,960
built in functions that we can work with.

9
00:00:31,980 --> 00:00:38,400
So just like we had a bunch of functions to work with, strings, which we saw earlier, things like

10
00:00:38,880 --> 00:00:41,260
canned cat and upper and lower.

11
00:00:41,280 --> 00:00:45,810
There's a bunch of functions on the docks that have to do with dates and times, and we're not going

12
00:00:45,810 --> 00:00:46,860
to learn all of these.

13
00:00:46,860 --> 00:00:49,380
There's a lot of them, but most of them are actually pretty simple.

14
00:00:49,650 --> 00:00:58,200
But within this grouping there are current date, current time and current time stamp, which we're

15
00:00:58,200 --> 00:00:59,520
not going to worry about right now.

16
00:00:59,520 --> 00:01:08,520
And then there's also Curr date, which is a shorter version cur time and then there is now an O and

17
00:01:08,520 --> 00:01:16,110
the three that I want to call your attention to right now are cur date and then cur time and now.

18
00:01:16,110 --> 00:01:22,110
Now those are actually shorter versions of current dates, current time and current time stamp.

19
00:01:22,110 --> 00:01:23,100
That's a little longer.

20
00:01:23,100 --> 00:01:26,880
So I usually just do cur date cur time and now, but they're the same thing.

21
00:01:26,970 --> 00:01:36,120
So let me just show you how they work in a simple select like select cur time that gives me the current

22
00:01:36,120 --> 00:01:42,360
time and it is indeed 255 or 1455 and 40 seconds for me.

23
00:01:43,170 --> 00:01:50,700
If I do cur date you can see oops, I had two semicolons so I got this extra error.

24
00:01:50,700 --> 00:01:54,840
But the current date is October 5th of 2022.

25
00:01:54,840 --> 00:01:56,550
I can't believe it's October already.

26
00:01:56,820 --> 00:01:57,570
Yikes.

27
00:01:57,780 --> 00:02:03,180
And then I have now as the other option and this gives me the current date time.

28
00:02:03,390 --> 00:02:06,420
So both the date and the time in that format.

29
00:02:07,050 --> 00:02:12,840
So I probably don't need to use my SQL as a calendar or as a clock, but I can.

30
00:02:13,980 --> 00:02:21,270
And just as a reminder, we could write it this way if you prefer current time instead of cur time.

31
00:02:21,270 --> 00:02:23,760
It's just shorter to do cur time.

32
00:02:23,760 --> 00:02:30,510
It's the same situation as upper and you case we have a shorter version, but they mean the same thing.

33
00:02:30,840 --> 00:02:34,950
So we have current date which can be shortened to cur date.

34
00:02:34,950 --> 00:02:43,770
Current time becomes cur time, but then if we have current time stamp, well that gets shortened just

35
00:02:43,770 --> 00:02:45,060
to now.

36
00:02:47,930 --> 00:02:49,250
And that gives us the same result.

37
00:02:49,280 --> 00:02:50,480
Of course, I ran it later.

38
00:02:50,480 --> 00:02:54,500
So the seconds have changed, but other than that, it's the same result.

39
00:02:54,710 --> 00:02:56,150
So we could use this.

40
00:02:56,240 --> 00:03:02,270
If I wanted to insert a new person into my database, somebody who is just born into people.

41
00:03:02,420 --> 00:03:04,190
Let's just do the same order.

42
00:03:04,190 --> 00:03:08,270
Birth, date, birth time and birth date.

43
00:03:08,300 --> 00:03:12,440
Make sure I spell date correctly and for values will pick a name like.

44
00:03:12,440 --> 00:03:12,830
Sure.

45
00:03:12,860 --> 00:03:13,640
Hazel.

46
00:03:13,880 --> 00:03:16,730
So Hazel was born right now.

47
00:03:16,730 --> 00:03:20,450
So for the dates portion, I'll do her date.

48
00:03:20,990 --> 00:03:23,750
And then for the time portion, I'll do her time.

49
00:03:23,840 --> 00:03:26,930
And then don't forget, it's not her date time.

50
00:03:26,930 --> 00:03:30,000
It's current time stamp or now.

51
00:03:30,000 --> 00:03:32,000
Now is easier to type.

52
00:03:32,420 --> 00:03:34,850
All right, so let's insert Hazel.

53
00:03:34,850 --> 00:03:35,990
She was just born.

54
00:03:36,380 --> 00:03:38,840
Select star from people.

55
00:03:38,840 --> 00:03:39,950
And there's Hazel.

56
00:03:39,950 --> 00:03:46,310
And we see the current date, the current time, and the current date time that we ran that query.

57
00:03:46,310 --> 00:03:50,510
So of course, if I ran it again, we would see a different time and a different date time.

58
00:03:50,510 --> 00:03:51,020
Here.

59
00:03:51,020 --> 00:03:52,160
The date would be the same.

60
00:03:52,160 --> 00:03:57,860
It's still the same day, but this is a really useful set of functions we can use if we ever need to

61
00:03:57,860 --> 00:04:01,280
access anything about the current date, time or date time.

62
00:04:01,520 --> 00:04:05,090
Next up, we're going to take a look at some of these other date and time functions.

63
00:04:05,090 --> 00:04:07,760
So we saw the current date, time, date time stuff.

64
00:04:07,760 --> 00:04:12,800
But what about things like month or minute or day of week, day name?

65
00:04:12,800 --> 00:04:14,840
We're going to see all of that coming up next.

