More About Oracle SQL Dates

I wrote about Oracle SQL dates yesterday. Here is some additional data. Dates are an integral part of any database system, and Oracle SQL is no exception. Oracle SQL offers a wide range of date formats that allow you to store, retrieve, and manipulate dates in a variety of ways. In this blog post, we will explore the various date formats available in Oracle SQL and how to use them effectively.

Date Formats in Oracle SQL

Oracle SQL supports a variety of date formats, including the following:

  1. Date Format

The default date format in Oracle SQL is ‘DD-MON-YY,’ which displays the date in the format of “Day-Month-Year.” For example, 05-MAY-21 represents May 5, 2021.

  1. Time Format

The default time format in Oracle SQL is ‘HH:MI:SS AM,’ which displays the time in hours, minutes, and seconds. The ‘AM’ or ‘PM’ indicator is used to represent the time in either morning or afternoon. For example, 08:45:30 PM represents 8:45 PM.

  1. Timestamp Format

The timestamp format in Oracle SQL is ‘DD-MON-YY HH:MI:SS.FF,’ which displays the date and time up to six decimal places. For example, 05-MAY-21 08:45:30.000000 represents May 5, 2021, at 8:45 PM and 30 seconds with zero milliseconds.

  1. Interval Format

The interval format in Oracle SQL is used to represent time durations, such as hours, minutes, and seconds. The interval format is expressed as ‘INTERVAL [n] [unit],’ where ‘n’ represents the duration and ‘unit’ represents the unit of time. For example, INTERVAL ‘5’ HOUR represents a duration of five hours.

Using Date Formats in Oracle SQL

To use date formats in Oracle SQL, you can use the ‘TO_DATE’ function. The ‘TO_DATE’ function converts a character string to a date value using the specified date format.

For example, the following query converts a character string to a date value using the ‘DD-MON-YY’ date format:

SELECT TO_DATE(’05-MAY-21′, ‘DD-MON-YY’) FROM DUAL;

The output of the above query would be ’05-MAY-21.’

In addition to the ‘TO_DATE’ function, Oracle SQL provides several other date functions, such as ‘SYSDATE,’ which returns the current date and time, and ‘ADD_MONTHS,’ which adds a specified number of months to a date.

Here are some common formats and and their usage:

FormatDescriptionExample
DD-MON-YYDay-Month-Year05-MAY-21
DD-MON-YYYYDay-Month-Four Digit Year05-MAY-2021
MM/DD/YYYYMonth/Day/Four Digit Year05/05/2021
DD/MM/YYYYDay/Month/Four Digit Year05/05/2021
DD-MM-YYDay-Month-Two Digit Year05-05-21
DD-MM-YYYYDay-Month-Four Digit Year05-05-2021
MON-DD-YYMonth-Day-Two Digit YearMAY-05-21
MONTH DD, YYYYMonth Day, Four Digit YearMay 05, 2021
DD/MM/YY HH24:MI:SSDay/Month/Two Digit Year Hour:Minute:Second05/05/21 20:30:00
DD-MON-YY HH:MI:SS PMDay-Month-Two Digit Year Hour:Minute:Second AM/PM05-MAY-21 08:30:00 PM
YYYY-MM-DDFour Digit Year-Month-Day2021-05-05
YYYY-MM-DD HH24:MI:SSFour Digit Year-Month-Day Hour:Minute:Second2021-05-05 20:30:00
Note that these are just a few of the many date formats available in Oracle SQL, and you can create your own custom date formats using the ‘TO_CHAR’ function.

Conclusion

In conclusion, Oracle SQL provides a wide range of date formats that allow you to store, retrieve, and manipulate dates in a variety of ways. Understanding the various date formats and how to use them effectively can help you work more efficiently with date data in your Oracle SQL database.

Oracle Date Formats

I have been writing Oracle SQL for many years but I constantly look up Oracle date formats. It is interesting what your brain stores and what it doesn’t. See below for common ones. I hope this helps someone.

MMNumeric month (e.g., 07)
MONAbbreviated month name (e.g., JUL)
MONTHFull month name (e.g., JULY)
DDDay of month (e.g., 24)
DYAbbreviated name of day (e.g., FRI)
YYYY4-digit year (e.g., 1998)
YYLast 2 digits of the year (e.g., 98)
RRSimilar to YY, but year digits are “rounded” to a year in the range of 1950 to 2049. So, 06 returns 2006 instead of 1906.
AM (or PM)Meridian indicator
HHHour of day (1-12)
HH24Hour of day (0-23)
MIMinute (0-59)
SSSecond (0-59)
These can be used with TO_CHAR or TO_DATE. Like this: TO_DATE(ADDED_DATE, ‘DD-Mon-YYYY HH24:MI:SS’)

Here are some links with more helpful information about Oracle dates.

http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html
https://www.oracletutorial.com/oracle-basics/oracle-date-format/

If A Blog Falls In the Blogosphere…

At one time people read this blog. It went dormant, it died, and it was stagnant. So, no one really knows it’s here. It would be better in some ways to produce short-form content like social media. Better maybe, but I get to choose.

Ah choice, ah freedom, I breathe it in and do not take it for granted.

So, one day will I publish a book of these posts? Maybe, but probably not. Will my kids stumble upon these moments, snapshots of what went on in my head? Maybe, but probably not.

Will these posts provide wisdom to a future generation? Will they make me rich and famous? Probably not.

What is the value of this digital log? Intermittent at best, it is a recording. That’s all no more no less.

Tips for Session Timeouts In .NET

Session timeouts are an important security feature for web applications, as they can help protect against session hijacking and other types of attacks. When implementing session timeouts in a .NET application there are a few best practices to keep in mind:

  1. Use a reasonable timeout value: The session timeout value should be set to a reasonable value that balances security concerns with user experience. A value of 20-30 minutes is often a good starting point, but you should adjust this based on your specific application and user needs.
  2. Notify the user before the session expires: It’s a good idea to give users a warning before their session is about to expire. This can be done by displaying a message on the page, or by using a pop-up or another notification method. This can help prevent users from losing their work if they are actively using the page when their session times out.
  3. Handle session timeouts gracefully: When a user’s session expires, you should handle it gracefully by redirecting them to a login page or other appropriate location. This should be done in a way that does not cause any errors or unexpected behavior for the user.
  4. Consider using a sliding expiration: A sliding expiration is a session timeout that is extended each time the user interacts with the application. This can help ensure that users do not lose their work due to inactivity, while still providing a reasonable level of security.
  5. Use HTTPS: When transmitting sensitive information, such as session tokens, it’s important to use HTTPS to encrypt the data and prevent it from being intercepted by attackers.

Overall, session timeouts are an important security feature for any web application and should be implemented carefully to ensure that they provide the necessary protection without unduly inconveniencing users. By following these best practices, you can help ensure that your .NET application provides a secure and user-friendly experience for all of its users.

My Own Worst Ememy

See below a poem by chatgpt…

I stand before a mirror, staring at my face A million thoughts inside my head, a million things to chase But as I look into my eyes, I see a glimpse of pain The kind that only comes from fighting with oneself in vain

I am my own worst enemy, I know this to be true I am the one who holds me back, the one who makes me blue I set the bar too high, then criticize myself for failing I push too hard, then wonder why I’m always ailing

I am my own worst enemy, I know this, without doubt, I am the one who fuels my fears, the one who breeds self-doubt I tell myself I’m not enough, that I’ll never reach my goals I sabotage my own success, then wonder why I’m in a hole

But I also know that I can change, I can break free. I can stop the negative self-talk, and be who I want to be I can be kinder to myself, and celebrate my wins. I can let go of the past, and start where I begin.

I am my own worst enemy, but I can be my own best friend I can lift myself up, and make the negativity end I can be my own champion, and rise above the rest I can be my own hero, and pass the ultimate test.

Perfect Is the Enemy of Good

Observations and Judgement

The one thing I have learned in my time here on earth is that people’s brains work differently. I am not discussing intelligence. Often we as a culture like we like to boil down people through judgments we make in work and life situations. We make an easy assessment like “smart” / “dumb” or “idiot” / “genius”. The truth is people have different intelligence quotients but day to day most of what we observe is not intelligence or lack thereof but differences in the way people’s brains process and work.

Brain Power

Some people can think quickly on their feet while some people require time to process. The processor does not possess less intelligence but their brain is examining many details and data points that need more time to process. I mention this because of how often we make a snap judgment about someone’s ability when we do not have enough data to make a judgment. These days our attention spans are so short, are we really gathering enough data to make an accurate assessment?

Process Improvement

I just mentioned we are busy, we have too many things on our plates and we have examined a situation or process that clearly needs automation and streamlining to result in the improvement of efficiencies. That part is easy, the actual time and work that is required is always the hard part. Our vision of the perfect solution may take 25 steps and require a lot of time, work, and maybe expense.

Smaller Bites

There is another solution perhaps, one that is still messy may still have manual elements and doesn’t fully automate. It costs less but takes more time daily and may require a hands-off approach to the process. It may mean giving the day-to-day work to another team member.

Fish or Cut Bait?

The problem is when you are the one who sees the whole board. You can see the 12 moves ahead and it is hard to hand off to another player who may only see the very next move. But, ultimately if they have time to manage the process you have to be ok with letting them fish.

Strategic Planning

I face situations like this personally and professionally every day. It’s hard but due to our limited bandwidth, crazy distractions, and just the craziness of life in general we will always be behind. The best we can do is prioritize projects strategically, empower and grow other team members, and save your bandwidth for the most important projects.

Your Best is Enough

Do your best, it’s the best you can do. It’s good enough.