Click here to Skip to main content
15,914,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear,
I want pass dateandtime in where condtion in which i want Fix Day and Fix Time but My Year and Month will Taken Current Month and year Eg. Current Month is March my query is Select * from TableName where Dateandtime = '2014-03-01 00:00:00'

For this i am trying Where Dateandtime = Convert(Datetime, datepart(yyyy,Getdate()+'-'+datepart(mm,Getdate()+'-'+'01 00:00:00'),120) but there is problem in converting in string format
please do needful.
Posted
v2

1 solution

Try this:
where Dateandtime = DATEADD(month,month(getdate())-1,DATEADD(year,year(getdate())-1900,0))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900