2

I'm trying to query using a where clause such as this: WHERE Today = a specific date .

This is what I have right now: DateAdd(day, 0, GetDate()) = '2018-02-12' (because it was 2/12 when I posted/tested this)

Help!

  • Could you please try WHERE cast(GetDate() As Date) = '2018-02-12' ? – Brad Sapkota Feb 12 '18 at 23:28
4

The CAST function in SQL converts data from one data type to another. By casting the GetDate() you're converting it to a string and comparing with a string in format of 'YYYY-MM-DD'.

You can do something like this:

WHERE cast(GetDate() As Date) = '2018-02-12'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.