Both will return "date parts" depending on your use one may make more sense to use then another.
LifeinAsia
3:59 pm on Jul 12, 2010 (gmt 0)
Depending on the language you're using (ASP, PHP, etc.), you should have a function called something like DateFormat that lets you format the date for output how you want.
hal12b
5:04 pm on Jul 12, 2010 (gmt 0)
I am using ASP.net with Visual Basic. I will take a look at the samples above. Thanks...
Question - Is there any real difference between DateTime and SmallDateTime? I was hoping SmallDateTime would only store the date, but it stores it with the time too.
Demaestro
5:40 pm on Jul 12, 2010 (gmt 0)
Smalldatetime still holds the time as the name suggests, it just uses less precision.
You can use ASP's date function to convert as well. You don't have to convert at time of select, you can convert at time of display if that is easier.
What you want is to call the function on a date object.
Assuming that Container.DataItem("DATE_OF_NEWS") is a proper date object that should work.
If it isn't you can cast it to a date then you can use the function on it.
hal12b
5:40 pm on Jul 16, 2010 (gmt 0)
It is a datetime field in the database, but I get an error -->
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
Line 36: Line 37: <% If Session("brokerlogin") = True Then%> Line 38: <%# Utils.CheckForNull_Text2(Container.DataItem("DATE_OF_NEWS").ToString("dd-MM-yyyy"))%> - <a href="<%# Utils.CheckForNull_Text2(Container.DataItem("HYPERLINK"))%>"> <%#Utils.CheckForNull_Text2(Container.DataItem("TITLE"))%></a> Line 39: <%Else%> Line 40: <%# Utils.CheckForNull_Text2(Container.DataItem("DATE_OF_NEWS"))%> - <%#Utils.CheckForNull_Text2(Container.DataItem("TITLE"))%>
Did you mean dd-MM-yyyy instead of dd-MMM-yyyy? Either way though, I get an error.
Demaestro
7:02 pm on Jul 16, 2010 (gmt 0)
hmm.
Try casting it to a date and see what happens.
Also can you get the error message and post it?
I would do it like this, it will be easy to step through it and see where it errors if at all.
print format_date (I can't remember if that is the syntax for displaying the variable. You may have to tidy up my syntax, which is why the error message will help.)