You need to know that GETDATE () returns the current date and time of day, not just today's date.
If you want to return strings matching today's date, you need to extract a portion of the date. There are several ways to do this β for example, with SQL Server 2008 you can use the DATE data type, but one common way to work with earlier versions of SQL Server is as follows:
CONVERT(DATETIME, convert(VARCHAR(10),getdate(),101) )
Then you can use the query:
SELECT trainid, trainnum FROM trains WHERE trainstartdate = CONVERT(DATETIME, convert(VARCHAR(10),getdate(),101) )
which will work if you are sure that the date / time in the trains.trainstartdate column is only a date (time of day = 0).
If trainstartdate contains a start date / time, you can get all of today's trains as follows:
SELECT trainid, trainnum FROM trains WHERE trainstartdate >= CONVERT(DATETIME, convert(VARCHAR(10),getdate(),101) ) AND trainstartdate < DATEADD(dd,1, CONVERT(DATETIME, convert(VARCHAR(10),getdate(),101) ))
By doing this, rather than converting to a string, you will use any index that may be in the trainstartdate column.