SQL count date time -
i have concatenate date , time portion of 2 fields, have managed do, need test if result < getdate()
select count(cast(cast(dischargedatenew date) datetime) + cast(dischargetime time))as requiredby [dbo].[main] location = 'home' , scripttypeid = '1' , requiredby < getdate()
unfortunately second requiredby
comes invalid column name. how can query work? need subquery?
yes need subquery:
select * (select someexpression requiredby [dbo].[main] location = 'home' , scripttypeid = '1') t requiredby < getdate()
but think want this:
select sum(case when cast(cast(dischargedatenew date) datetime) + cast(dischargetime time) < getdate() 1 else 0 end) requiredby [dbo].[main] location = 'home' , scripttypeid = '1'
Comments
Post a Comment