views:

28

answers:

2

hi

In my application (asp.net) I am uploading the video and storing the video in database like videoname,videotitle,dateofuploded these are the fields. My problem is when I am displaying that video I want to display the date like '2 days ago' or ' one month ago' or 'one year ago'

How can I write the function for converting the date into that process.

Take example of youtube. On that site below the video display the date when it was uploaded.

Can I get that format of date if yes how can I write that.

Thank you

A: 

I don't know any built-in SQL functions that can do this, so i think you'll have to write some code for that.

See timespan-to-friendly-string-library-c for a C# example on how to do this.

Am
ya Mr. Am i referred that link is it c# code or sql command
Surya sasidhar
ok it is C# code
Surya sasidhar
can we write in sql
Surya sasidhar
you better of doing it in the application. SQL isn't the native place for such transformations. If you do want to do it in SQL, you will to write a function (stored procedure) that will do the conversion.
Am
ya Mr. Am i understood
Surya sasidhar
+2  A: 

The database is probably not the best side of the fence on which to do this. Because it's purely for visual purposes, it belongs in the UI layer of the application code.

Because the range of values (days, weeks, months, years) is finite, it doesn't have to be anything fancy, just a big if statement.

Quick Joe Smith
ok Thank your Mr. Quick Joe Smith for response i will do on C#
Surya sasidhar