Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Datamart SQL and SYSDATE

Hi 

 

I am looking at developing a datamart and have pulled in tables from Oracle, I want to write a SQL statement for a table using 

xx_end_date is null or xx_end_date > sysdate 

 

This is not working on the datamart SQL. Does anyone have a solution to this?

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

It seems that the SQL statement you provided is not working on the datamart SQL. One possible solution is to use the function to check for null values and then convert the date to a string so it doesn’t try to convert ‘’ to a date.

Below is my table:

vxiandatmsft_0-1705556038393.png

The following SQL might work for you:

SELECT 
    CASE 
        WHEN xx_end_date IS NULL THEN '' 
        ELSE CONVERT(varchar, xx_end_date) 
    END 
FROM 
    [dbo].[DimDate] // yourtablename
WHERE 
    xx_end_date IS NULL OR xx_end_date > GETDATE()

The final output is shown in the following figure:

vxiandatmsft_1-1705556104791.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Didn't need to convert null to a date, just needed to use GETDATE( ) instead of SYSDATE( )

Anonymous
Not applicable

Hi @Anonymous ,

It seems that the SQL statement you provided is not working on the datamart SQL. One possible solution is to use the function to check for null values and then convert the date to a string so it doesn’t try to convert ‘’ to a date.

Below is my table:

vxiandatmsft_0-1705556038393.png

The following SQL might work for you:

SELECT 
    CASE 
        WHEN xx_end_date IS NULL THEN '' 
        ELSE CONVERT(varchar, xx_end_date) 
    END 
FROM 
    [dbo].[DimDate] // yourtablename
WHERE 
    xx_end_date IS NULL OR xx_end_date > GETDATE()

The final output is shown in the following figure:

vxiandatmsft_1-1705556104791.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.