Discover our Clipsal Smart Home packages as seen on the Block

in location

OR

I'm looking for

  • Wholesalers
    • Uncheck All Check All
  • EXPERTISE
    • Expand
    • Expand
    • Expand
    • Uncheck All Check All
  • Switchboard Manufacturers
    • Uncheck All Check All
OR

The best way to see what Clipsal electric products can do for your home is seeing them in action at a Clipsal Display Centre.

Product stock may vary according to location. If you're after a specific product range, please check with your chosen location before visiting.

10 Results
    Load More Load Complete
    Change Location

    How to create SQL queries that return specific calculated dates respective to today's date and to avoid hard coding these dates within the query itself

    Issue
    How to create SQL queries that return specific calculated dates respective to today's date and to avoid hard coding these dates within the query itself.

    Product
    Struxureware Power Monitoring
    Power Monitoring Expert
    ION Enterprise
    ION EEM

    Environment
    SQL Server (any version)

    Resolution
    *Warning: Irreparable database damage can occur. This procedure should only be performed by users familiar with SQL Server Management Studio. Databases should be backed up prior to performing this procedure.* 

    The following sample queries (ex. 1-5) depict the use of various SQL functions to calculate and return specific dates respective to today's date. 
    These SQL queries can then be used as sub-queries within another SQL query's WHERE clause to retrieve specific period of data based on the dynamically calculated date range. (ex. 6)  The below queries illustrate just a small sample of the possible use cases. These can be used in many other situations and tailored to meet your specific requirement.

    1) Select CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())),GETDATE()),101) AS Date_Value, 'Last Day of Previous Month' AS Date_Type

    2) Select CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(GETDATE())-1),GETDATE()),101) As Date_Value, 'First Day of Current Month' AS Date_Type

    3) Select CONVERT(VARCHAR(25),GETDATE(),101) As Date_Value, 'Today' As Date_Type

    4) Select CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,GETDATE()))),DATEADD(mm,1,GETDATE())),101) As Date_Value, 'Last Day of Current Month' As Date_Type

    5) Select CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,GETDATE()))-1),DATEADD(mm,1,GETDATE())),101) As Date_Value, 'First Day of Next Month'As Date_Type

    6) Select * from EEM_DataLog
           WHERE
        TimestampUTC >=  (SELECT CONVERT(VARCHAR(25),GETDATE(),101))
           AND
        TimestampUTC <=  (SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,GETDATE()))),DATEADD(mm,1,GETDATE())),101))

    Didn’t find what you were looking for?

    Try Searching Again View Our Categories

    Need further assistance?

    Our Customer Care department provides total customer service solutions for our residential, industrial and commercial applications.

    Get Assistance