T Daily text variable – 4 Daily Detail variable tracked every 4 hours – G 4 hour calc. – E 4 hour text variable – H Daily Detail variable tracked every hour – N Hourly Calc – B Hourly Text – 3 Daily Detail variable tracked every 30 minutes – W 30 Minute Calc – Q 30 Minute Text – F Daily Detail variable tracked every 15 minutes – V 15 Minute Calc – X 15 Minute Text – 5 Daily Detail variable tracked every 5 minutes – Y 5 Minute Calc – R 5 Minute Text – 1 Daily Detail variable tracked every minute – S Minute Calc – A Minute Text – So I want C,G,N,W,V,Y,S. I could do a bunch of ORs, however SQL has an IN clause: Example 12: Show daily data edited since yesterday Example 13: Show daily data edited since yesterday where yesterday is calculated I want to show daily data edited since yesterday but I want to calc the date so I don’t have to change the query every day. I need to calculate yesterday’s date. So google it. Search for sql get yesterday date”. T SQL is “t Microsoft SQL Server’s variant of SQL (stands for Transact SQL). GETDATE() Returns current date time – DATEADD Adds or subtracts a number of days, months, etc.. to a date – CONVERT Formats values, e.g. Used to cutoff time part. – DATEDIFF Returns the specified time (days, months) between dates – Select GetDate(),DateAdd(day,-1,GetDate()),CONVERT(Char(10),DateAdd(day,-1,GetDate()),101)
T – Daily text variable 4 – Daily Detail variable tracked every 4 hours G – 4 hour calc. E – 4 hour text variable H – Daily Detail variable tracked every hour N – Hourly Calc B – Hourly Text 3 – Daily Detail variable tracked every 30 minutes W – 30 Minute Calc Q – 30 Minute Text F – Daily Detail variable tracked every 15 minutes V – 15 Minute Calc X – 15 Minute Text 5 – Daily Detail variable tracked every 5 minutes Y – 5 Minute Calc R – 5 Minute Text 1 – Daily Detail variable tracked every minute S – Minute Calc A – Minute Text So I want C,G,N,W,V,Y,S. I could do a bunch of ORs, however SQL has an IN clause: Example 12: Show daily data edited since yesterday Example 13: Show daily data edited since yesterday where yesterday is calculated I want to show daily data edited since yesterday but I want to calc the date so I don’t have to change the query every day. I need to calculate yesterday’s date. So google it. Search for “t sql get yesterday date”. T SQL is Microsoft SQL Server’s variant of SQL (stands for Transact SQL). GETDATE() – Returns current date time DATEADD – Adds or subtracts a number of days, months, etc.. to a date CONVERT – Formats values, e.g. Used to cutoff time part. DATEDIFF – Returns the specified time (days, months) between dates Select GetDate(),DateAdd(day,-1,GetDate()),CONVERT(Char(10),DateAdd(day,-1,GetDate()),101)
SQLBasicTraining.Docx