Last post Nov 26, 2014 11:37 AM by limno
Nov 26, 2014 11:06 AM|SmokinJoe|LINK
I am having trouble with SQL syntax to retrieve records with [ExpirationDate] [DateTime field type] with a date 30 days from the current date.
I have been playing with the following, but it does not work...
Any assistance would be appreciated.
Please make it a Happy "Thanks-giving"!
Posted to the database as ExpirationDate= 2014-11-30 00:00:00.000
Nov 26, 2014 11:15 AM|limno|LINK
Where ExpirationDate >= dateadd(day,datediff(day,0,GETDATE()),0) AND ExpirationDate < Dateadd(day,30,GETDATE()) and AND ForwardedtoProgram=62 AND [ProdCategory]=7
Nov 26, 2014 11:19 AM|gimimex|LINK
Try to remove a close parentheses after the second date:
ExpirationDate Between Cast(GETDATE() AS DATE) AND CAST(DATEADD(d, 30, GETDATE()) AS DATE) AND
ForwardedtoProgram = '62' AND
[ProdCategory] = '7'
Hope this helps.
Nov 26, 2014 11:27 AM|SmokinJoe|LINK
Happy Thanksgiving - - Wherever you are!
Thanks to all who replied!!
Nov 26, 2014 11:37 AM|limno|LINK
If you are interested, you can have a quick look at this one:
Try to use the right data type for your query and when you put your number inside single quotes, do you really have sting data type for the column. If they are numeric, don't use single quotes around them.