This example illustrates how to select records from a table based on the current date.
Create Table TestDate ( PKCol Int Primary Key, DecDate Decimal( 9,0 ), CharDate Char( 8 ) ) Insert Into TestDate Values ( 1, 20010711, '20010711' )
Select * From TestDate Where DecDate = 100 * ( 100 * Year( CurDate() ) + Month( CurDate() ) ) + Day( CurDate() )
Select * From TestDate Where CharDate = Cast( 100 * ( 100 * Year( CurDate() ) + Month( CurDate() ) ) + Day( CurDate() ) As Char( 8 ) )
Use care when converting a Month() or Day() return value to a character with Cast. If you do not explicitly handle values less than 10, there might be spaces instead of zeros in the result.