0

I want to find few data from SQL Server that only query by current date. The purpose is to view today transaction only

Here is my code

SELECT * FROM dbo.Student.studentProfile
WHERE TransactionDate = curdate()

RESULT

Curdate is not a recongined built-in function name

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
MUHD MAN
  • 55
  • 1
  • 10

3 Answers3

4

If you are looking for the current date:

WHERE TransactionDate = cast(getdate() as date)

Or if you prefer ANSI standards:

WHERE TransactionDate = cast(CURRENT_TIMESTAMP as date)
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
2

Different sql implementations (ie SQL Server, Mysql, postgresql etc) can have different methods supported. For SQL Server the method you want to use is GETDATE() instead of CURDATE()

The documentation for this method is here: https://msdn.microsoft.com/en-us/library/ms188383.aspx

vicg
  • 1,280
  • 14
  • 32
0

Try this.

select * from dbo.Student.studentProfile
    WHERE TransactionDate >= dateadd(day,datediff(day,1,GETDATE()),0)
        AND TransactionDate < dateadd(day,datediff(day,0,GETDATE()),0)
aadarshsg
  • 2,069
  • 16
  • 25
  • TQ for response. I already try the code you given. No error and no output, meanwhile have today date in my table. – MUHD MAN Jun 12 '15 at 01:20