I am fetching a date type variable from DB… And what to proceed if the date is more than 15 days ago from current date. Need some help in this. Kindly help me to use datetime variables…
I am fetching a date type variable from DB.. And what to proceed if the date is more than 15 days ago from current date. Need some help in this. Kindly help me to use datetime variables
This will help you for sure…
Thanks Hareesh. How can I check this in an SQL query? I am trying to do this but I need to convert Now function to String but my retrieved data from DB is date type.
Get the value from db and store it in a date type variable and use this …
DateTime.ParseExact(your variable here, “DD/MM/yyyy” ,Globalization.CultureInfo.InvariantCulture
the variable in DB is Date type itself… If I want to fetch records that have that column value less than today’s date; what should I do?
That you can do in the query itself right? @Pankit
Try this where condition…
SELECT DATEADD(day, DATEDIFF(day, 1, GETDATE()), 0)
Tried a similar Query in SQL Server 2014 and it worked.
select * from table_name where DATEDIFF(day, colume_name, GETDATE() ) > 15 ;
This gave results for rows containing date before 5 days from current date.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.