Hi guys.
I have a datetime data type column set up for keeping dates. 12:00am would like to hang around when I don't want it too. I don't know if the best solution is to have the server format it for me or if that should be done on the client side. In either case I need a little guidance. My app is a simple blog program that uses a dataset to populate a datalist from mssql 2005. I've looked through some of the other entries that people have posted but I'm to new to this particular issue and sql to transcribe their issue's fix to mine... at least from the enties I've read so far. hence my requst for help! Your assistance is greatly appreciated.
Mucho thanks.
Fatthippo.
You can format the datetime either way, but it would be better by doing it from client side. For example,
<ItemTemplate>dob:<asp:Label ID="dobLabel" runat="server" Text='<%# Bind("dob","{0:MM/dd/yyyy}")%>'></asp:Label></ItemTemplate>|||
Thankyou limno!
that satifies the questions but if I'm always formatting what comes out of mssql and not what's going in, will that hinder any search querries I might want to do in the future if 12:00am is always at the end? In otherwords, is there a benfit or downside to using the technique in the above example?
Thanks again!
Fatthippo
|||Datetime data type has two parts date and time. It should be a good practice to use datetime this way instead of as a string type. From my limit knowledge, we should choose to do this sort of formating from client side to save a little bit extral calculation on database engine. There are other ways to format date time to fit your need. You can look it up depending on what kind of control you are using. When I am working on my projects, I use them interchangably in light load applications. But without further testing, I cannot give you any firm recomendation on this. You can search for this information from various forums and I am sure you will get a lot of information on this. I like to play with formating datetime in SQL to learn.
No comments:
Post a Comment