Converting a selected date from a datetimepicker into my query, along with subtracting a day
Posted
by
MyHeadHurts
on Stack Overflow
See other posts from Stack Overflow
or by MyHeadHurts
Published on 2011-01-05T18:40:35Z
Indexed on
2011/01/05
18:54 UTC
Read the original article
Hit count: 210
sql
|sql-server-2005
I am currently using this to get yesterdays date, however i need to do something similar where the user will use a javascript datetimepicker in my asp.net page
and i will then use the date they select instead of just yesterdays date
Declare @dayselection int
set @dayselection = CONVERT(int,DateAdd(year, @YearToGet - Year(getdate() + 1),
DateAdd(day, DateDiff(day, 1, @dayToGet), 1) , DateAdd(month, DateDiff(month, 0, @monthToGet), 0) )
but it isnt working i keep getting syntax errors
I want the day and year functions to stay the same i just need help with the month part.
I need to convert the selected date into an int
© Stack Overflow or respective owner