Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Oct 21, 2010 04:56 PM by limno
Participant
1066 Points
1035 Posts
Oct 21, 2010 04:20 PM|LINK
hello santhosh, the datetime in database is already getting stored in UTC
after struggling with this thing i figured out a way as i am using date picker, by using following i am getting correct date and time according to my set time zone.
<%#DateTimeHelper.ConvertToUserTime((DateTime)Eval("RegistrationDate"), DateTimeKind.Utc).ToString()%>
The output is being displayed as: (10/18/2010 3:13:07 PM)
Now can you help me how i can modify the above code to display the output like this -> (Wednesday, October 20, 2010 at 1:36pm) ?
All-Star
117314 Points
7997 Posts
Moderator
MVP
Oct 21, 2010 04:56 PM|LINK
To convert database UTC datetime into Server local datetime (RegistrationDate is UTC datetime retrieved from database):
VB.NET:
C#: <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# String.Format("{0:f}", ((DateTime)Eval("RegistrationDate")).ToLocalTime()) %>' ></asp:Label> </ItemTemplate>
C#:
ASP__DEVELOP...
Participant
1066 Points
1035 Posts
Re: how to convert date type in SQL query output ?
Oct 21, 2010 04:20 PM|LINK
hello santhosh, the datetime in database is already getting stored in UTC
after struggling with this thing i figured out a way as i am using date picker, by using following i am getting correct date and time according to my set time zone.
<%#DateTimeHelper.ConvertToUserTime((DateTime)Eval("RegistrationDate"), DateTimeKind.Utc).ToString()%>
The output is being displayed as: (10/18/2010 3:13:07 PM)
Now can you help me how i can modify the above code to display the output like this -> (Wednesday, October 20, 2010 at 1:36pm) ?
(Online Forums: ASP.NET, SQL, C#, MS Office, Photoshop and much more)
limno
All-Star
117314 Points
7997 Posts
Moderator
MVP
Re: how to convert date type in SQL query output ?
Oct 21, 2010 04:56 PM|LINK
To convert database UTC datetime into Server local datetime (RegistrationDate is UTC datetime retrieved from database):
VB.NET:
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm