Suppose that you need to send an email alert to your customers to remind them to pay the invoice bill after 30 days of invoice generation as per their contract. Hence, you have to write an SQL based program to check all the unpaid invoices which comes under this conditions.
Value (any one of)
|
Explanation
|
year, yyyy, yy
|
Year interval
|
quarter, qq, q
|
Quarter interval
|
month, mm, m
|
Month interval
|
dayofyear
|
Day of year interval
|
day, dy, y
|
Day interval
|
week, ww, wk
|
Week interval
|
weekday, dw, w
|
Weekday interval
|
hour, hh
|
Hour interval
|
minute, mi, n
|
Minute interval
|
second, ss, s
|
Second interval
|
millisecond, ms
|
Millisecond interval
|
----
Difference in years
SELECT
DATEDIFF(year, '2012/04/28', '2014/04/28');
Result: 2
----
Difference in months
SELECT
DATEDIFF(month, '2014/01/01', '2014/04/28');
Result: 3
----
Difference in days
SELECT
DATEDIFF(day, '2014/01/01', '2014/04/28');
Result: 117
----
Difference in hours
SELECT
DATEDIFF(hour, '2014/04/28 08:00', '2014/04/28 10:45');
Result: 2
----
Difference in minutes
SELECT
DATEDIFF(minute, '2014/04/28 08:00', '2014/04/28 10:45');
Result: 165
|
To watch a demo video, please visit our YouTube channel -
Hope you enjoyed and found this essay useful. Please leave your questions and suggestions in the comments section. Many thanks for reading! 😊
Your support is greatly appreciated! If you found this article valuable, don’t forget to clap👏, follow✌️, and subscribe❤️💬🔔 to stay connected and receive more insightful content. Let’s grow and learn together!
⭐To learn more, please follow us —
http://www.sql-datatools.com
⭐To Learn more, please visit our YouTube channel at —
http://www.youtube.com/c/Sql-datatools
⭐To Learn more, please visit our Instagram account at —
https://www.instagram.com/asp.mukesh/
⭐To Learn more, please visit our twitter account at —
https://twitter.com/macxima
⭐To Learn more, please visit our Medium account at —
https://medium.com/@macxima
Nice Post Thanks For Sharing
ReplyDeleteBusiness intelligence tools