Announcement

Collapse
No announcement yet.

Need a little MSSQL help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need a little MSSQL help

    One of the servers (infact them all) use MSSQL at work.

    I'm editing a query but I want to know if this does as expected

    convert(datetime, CONVERT(CHAR(12),(GETDATE()+(CASE WHEN (DATEPART(month, GETDATE()+65) < 4) THEN 65*(4-DATEPART(month, GETDATE()+65)) ELSE 65 END)),3)+ ' 23:59:59'))
    Code:
    convert(
    	datetime, 
    	CONVERT(CHAR(12),(
    		GETDATE()+(
    			CASE WHEN 
    				(DATEPART(month, GETDATE()+65) < 4) 
    			THEN 
    				65*(4-DATEPART(month, GETDATE()+65)) 
    			ELSE 
    				65 
    			END
    		)
    	),3)+ ' 23:59:59'))

    What it needs to do is
    This bit here
    (GETDATE()+(CASE WHEN (DATEPART(month, GETDATE()+65) < 4) THEN 65*(4-DATEPART(month, GETDATE()+65)) ELSE 65 END))

    On GETDATE()+65 = jan return 65*3
    On GETDATE()+65 = feb return 65*2
    On GETDATE()+65 = mar return 65
    On GETDATE()+65 >= Apr return 65

    I cant edit the whole query, just that the where, as I dont have access to the entire query.
    I cant test either as the systems locked off, I only have blind access via the client for the Patient Access System.
    So if it messes up i cant tell why.
    Anyone know if that works...




    I'm not insane. I'm just overwhelming!

    ·····••••• Support Cainslair. Donate here!•••••·····
    ·····••••• and get extra options! •••••·····

    #2
    Perhaps download the Express Edition to test it out locally?
    --Slaughter

    Comment


      #3
      I found this site...
      New to me, but it worked.
      It also proved my math is bad XD

      http://sqlfiddle.com/#!3/4f1ee/42




      I'm not insane. I'm just overwhelming!

      ·····••••• Support Cainslair. Donate here!•••••·····
      ·····••••• and get extra options! •••••·····

      Comment

      Cain's Lair Forums Statistics

      Collapse

      Topics: 26,182   Posts: 269,814   Members: 6,176   Active Members: 3
      Welcome to our newest member, 28Farrell8.

      Today's Birthdays

      Collapse

      There are no members with birthdays today.

      Top Active Users

      Collapse

      There are no top active users.
      widgetinstance 184 (More Posts) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X