Posted by fjleon on 10/02/21 11:48
This seems to work but it is way ugly and depends heavily on the date
format:
select
cast(cast(mymonth as varchar(2))+'/'+cast(myday as
varchar(2))+'/'+cast(myyear as varchar(4)) as datetime)
from mytable
where cast(cast(mymonth as varchar(2))+'/'+cast(myday as
varchar(2))+'/'+cast(myyear as varchar(4)) as datetime)
between '20060520' and '20061231'
Also, i tried to use an alias on the select but then it doesn't get
recognized on the where so i had to type it full again.
Anyone knows a better way? Asp has a dateserial() method that
constructs a date given a month , day and year, but sql server doesn't
seem to have anything like that as a sql date function.
Navigation:
[Reply to this message]
|