Click here to Skip to main content
15,903,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi...

i've one table called thoughts
in that i've two fields
date and thoughts

now in front end that is in .aspx page C# code
there's one textbox and one submit button.
when i enter text into textbox it should save
in thought table with the date..
the date should be in increment order..

i.e if i enter the data one time today then today's date.
if i enter the date two times tommorrows date
if i enter the date three times day after tommorrow's date..

actually i want to enter the thoughts for one year that is
365 thoughts and i want to retrive the thought by date..

Please help me..
Posted

Do you mean that you add a row for the next day based on existing rows. Then the statement could be something like:
SQL
insert into Thoughts (TheThought, DisplayDate)
SELECT 'Some thought', COALESCE(MAX(DATEADD(Day, 1, Display)) , GETDATE())FROM Thoughts


However there are several other ways to resolve the date problem without fixing it into the database. For example selecting Nth row based on some date could also be a usable solution.
 
Share this answer
 
v2
Comments
fjdiewornncalwe 18-Feb-11 14:38pm    
My interpretation of this question is the same as yours and I like your solution. +5.
Wendelius 19-Feb-11 2:08am    
Thanks :)
Hi This will return thoughts for the day (18-Feb-2011) that you passed.

SQL
SELECT * From Thought WHERE CONVERT(VARCHAR(10), ThoughtDate, 101) = '02/18/2011'  --[MM/DD/YYYY]



Thanks,
Imadhusen
 
Share this answer
 
Comments
vinu.1111 18-Feb-11 8:07am    
thanks for reply..
but i want to insert into table based on date in incremant order...
RaviRanjanKr 18-Feb-11 8:09am    
have a my 5!
Sunasara Imdadhusen 18-Feb-11 9:14am    
You need to write script for INSERT statement!

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