Forum Discussion

Uno1283's avatar
Uno1283
Copper Contributor
Nov 17, 2023

Script help

Hi all

 

i am hoping someone can help me. 

the script below does not work. Can someone help me please? 

select *

from 
(

select *, convert(varchar,[updatedat],3) as [updatedatdate)

from tlbReopen

) at table1

where datediff(mom,[updateatdate], getdate ()) <=1

1 Reply

  • LainRobertson's avatar
    LainRobertson
    Silver Contributor

    Uno1283 

     

    Hi, Gary.

     

    There's a lot of syntax errors there and for some we can only guess what you might have intended.

     

    Here's my best guess based on what you've provided:

     

    SELECT
    	*
    FROM
    	(
    		SELECT
    			*
    			, CONVERT(varchar, [updatedat], 3) as [updatedatdate]
    		FROM
    			[tlbReopen]
    	) AS [Table1]
    WHERE
    	DATEDIFF(mm, [updateatdate], GETDATE ()) <=1

     

    If this isn't what you were after, then can you please provide the following so we have a better idea of what you're trying to do and what you're working with:

     

    • Details of the error - i.e. include the exact message;
    • Example data from tblReopen (it doesn't have to be real values, but we need to see samples);
    • For the final "DATEDIFF" line, tell us which date part you're hoping to use, as "mom" is not valid;
    • If you can put your code in a code box, that makes it easier for us to read.

     

    Cheers,

    Lain

Resources