Skip to Main Content

SQL Page Timeframe

This SQL Page Timeframe dashboard demonstrates how the current date and time are displayed, along with an example utilizing the Page Timeframe feature of SquaredUp.

Shawn Williams, SquaredUp

Challenge

When writing a SQL query, getting the date and time to format correctly can be a real pain. What is the current date and time, and how is it formatted? What happens if I want the date and time from 30 days ago? Is there a dashboard that demonstrates how to manipulate date and time for SQL Queries?

Solution

This SQL Page Timeframe dashboard demonstrates how the current date is picked up from the server hosting SquaredUp and how the Page Timeframe button impacts the date and time in a SQL query. Several different examples are demonstrated.

Dashboard walk-through

Each time on the dashboard does something different with the Date and Time. Here is how it breaks down:

  1. Tile 1 (SQL Native) – A simple query that uses the Current_Timestamp function but formats the date and time in a specific way.
  2. Tile 2 (Page Time Frame) – A Case statement the demonstrates how the Page Timeframe is passed into a SquaredUp tile.
  3. Tile 3 (Current Time with Time Zone) – A Select query utilizing the SysDateTimeOffset function and formats the Date and Time with the time zone. The formatting used is different from the formatting used in Tile #1.
  4. Tile 4 (Time zone of the server) – The Time Zone of the server hosting SquaredUp. This information is essential to note when working with a server in a different time zone.
  5. Tile 5 (SQL GetDate Function) – A cornucopia of Date and Time values formatted for each Page Timeframe selection. These are hardcoded so that for comparison purposes with Tile #6.
  6. Tile 6 (Page Time Frame) – Demonstrates how to use the dynamic page timeframe feature. Plus, it includes some date manipulation to change how you want the starting date. For example, start at midnight of the target day, or target the same time as now.
GET STARTED TODAY

Zero to dashboard hero in 60 seconds

Start now with hundreds of customizable dashboards.