Hello again, my dear friends.
So in this section, we're going to learn daytime functions now.
There just happen to be quite a few of them.
So let me list a few.
We're going to learn, get date function.
Is date function.
Do I have a date function?
No, I'm just kidding.
Day, month and year functions, date, part, function, date, name, function.
Date and function.
As well as the date diff function.
So why don't we get started with the get date function?
Now, the get date function will return the current system date and time of the operating system on
which the Escorial servers running dynamic since.
So let's jump over and into SSME and get the date and time.
The select get date keywords will get the date and time of the system.
They get the key word must be finished with Prince's.
And then execute the query.
So here is the current date and time of our machine.
And this function returns the date and time of the system on which the Escorial servers running, so
obviously yours may be a little different.
Now, the next function that we're going to learn is the is date function.
So the is date function checks and expression and returns one.
If the expression is a valid date, otherwise zero will be returned.
So let's have a look at the syntax of this function.
And it takes an expression in parentheses.
His date function takes only one parameter.
So in this example, we will use the get date function as a parameter.
Now, if you excuse the query, it will return one.
This means that the expression is a valid date.
So the get date function returns the date and time and the system.
The expression can also be used as a parameter.
So this query will also return one, because the expression is a valid date.
So now let's see what happens when you use a string as an expression.
For instance, a string can be SQL Server.
Let's execute this query and it will return zero because the specified expression is not a valid date
day function.
So this function returns the day of the month for a specified date, and it's going to return a number
between one and 31, of course, depending on the month.
So here is a syntax.
And it will take a validate and return it's day.
And the day of this date is 20.
Month function.
Of course, it returns a month of a specified date as an integer.
That will return a number between one and 12.
And here is a syntax of that.
And it'll take a validate and return its month value.
And the month of this date is one.
The year function.
So this function will return the year of a specified date as an integer.
And here's the syntax of it, and it takes the validate and returns, it's your value, your this date
is 20-20.
So let's do an example for each function.
Now, the day function returns the day the specified date, so let's make sure the expression specified
is valid date.
If we execute the query, 20 will be returned as the day of this expression, so that's correct.
The month function will return one as a month of this expression.
And the year function will return 2020 as the year this expression.
That part function.
So the date part function will return the part of date or time.
So this function will return an integer, which is part of a date such as day, month or year.
The date part function takes two parameters, the first parameter is the part of the date to be extracted
and then the second parameter is the date from which the date part is extracted.
Now, as you might imagine, there are many date parts that can be used as the first parameter.
For instance, there are three ways to get the year value from the specified date.
The year keyword or for why letters or double why letters return the same value.
And of course, you can use any of them to get your value, so the other date parts are quarter, month,
day of your day, week, weekday, hour, minute, second, even millisecond.
Now, the date part function will take two parameters, the first parameter will be the year and the
second one must be a valid date.
So if we asked you the query, we will get 20/20 because we have specified the year as the first parameter.
So instead of using the turkey word, we could use the double why?
Or the four y letters to get the same result.
And the day keyword will return the day of this date time as an integer, and it'll return 20 in this
case.
The month keyword will return the month of this date time as an integer.
And it's going to return one.
The our keyword will return the hour of this date time as an integer, and it'll return for.
And when we press a letter M from the keyword, all other date parts, starting with the letter M will
be listed.
The am I keyword will return the minute of this date time as an integer, and it returns 55.
We can use a minute keyword instead of the main keyword to get the minutes of this date time as an integer.
So to wrap that up, the date part function returns integer values.
So here's the date name aFunction.
The date name function will return the party date or time, and his function returns a string, which
is part of a date such as day, month and year.
The date name function takes two parameters the parameters of this function are the same as the parameters
of the date part function, however.
Year, quarter, month, day of the year, day, week, so on.
The date name function takes two parameters, the first parameter will be year, and I'll put the second
one, it must be a valid date.
So if we execute the query with a minute keyword as parameter, we'll get 55.
Like the date part function.
And the day keyword will return the day of this daytime as a ed.
And in return, 20.
Just like the date part function.
Now, let me show you something here, when we use the month as a parameter, it will not return.
One, the name of the first month will be returned, right.
It'll return January.
So here's the main difference between the date name and the date part you might have even anticipated.
Now.
So while the date part function returns, a month is an integer, the daytime function returns the name
of the month.
Now, if we use the weekday for both functions.
The date part function will return the two as a weekday, but the date name function will return Monday
as a weekday.
The day of the year keyword will return 20 for both functions.
And check this out, the letter Q or double Q or quarter as a keyword will return the quarter a year.
So that wraps up the date name function, it returns string values if it's possible, otherwise it will
return integers just like the date part function.
The date and function.
So the date and function will display the date and time by adding or subtracting date and time intervals.
So this function will take three parameters.
The first one is the part of the date to which the date and function will add the number.
The second parameter is the number, which is an integer number to be added to the first parameter of
the given validate.
So the value evaluates to a decimal or float the function date and will truncate the decimal fraction
part and it will not round the number in this case.
And the last parameter is the expression, and it must be a valid date.
So these given keywords, such as month, day of year, day, week, hour or one of the others can be
used instead of using the year keyword as the first parameter.
Let's see what it looks like, an SS, a mass.
The data add function takes three parameters, the day is the first parameter, the number five is the
second one, and the date is the last parameter.
So this query will return the date five days after the date and time from the current date and time
and Ms.
Escarole server.
And when we execute it, we will see that the day of the date has been changed to 25.
Now, the number minus five will decrease the day of the date and it will be changed to 15.
Now, the first parameter has been changed to month.
It means that the month will be changed.
And this query will return after five months and it will be changed to six.
If the first parameter has been changed to the year keyword, it means that the year will be changed.
And this query will return the after five years and it will be changed to 20, 25.
And the last function that we're going to learn here is the date dysfunction.
So this function will display the date and time between two dates, so this function accepts three parameters.
The first one is the part of the date, for instance, a year, a quarter, a month, a week that you
want to compare between date one, which is a start date and date two, which is the end date.
The second and the final parameters are date one and date to which are the dates to be compared.
Now, instead of using the year keyword, we can use quarter, month, day, week, our minute one of
the others.
And the day dysfunction will return a difference in the date part between the two dates.
And this function takes three parameters, the keyword will be the first parameter and the other parameters
must be valid dates.
And then this query will return the difference of years between 1989 and 2020.
And then that way, when we execute it, the result will be 31 years.
And that's the difference between these two dates.
Now, what about the number of days between these two dates?
By using the day function as the first parameter, we can return the total number of days between these
two dates and here's that result.
You can also find a number of days you have lived since your birthday with the date dysfunction.
Oh, that's always fun.
Even more, the hours or seconds or even milliseconds that you've lived can be found by using this function
in escarole server.
So in this case, the get date function should be used instead of the end date to calculate and up to
date value.
Excellent.
So this is a section that we learned that time functions.
Now, in the following section, we're going to learn daytime convergence, so I want to see their.