Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 9th, 2008, 08:12 PM
Registered User
 
Join Date: Apr 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting Epoch Time to Readable Date

I have a column that stores the number of seconds the number of seconds since Jan 1, 1970

My Grid looks like this in my code -

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px"

CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="Black"

GridLines="Vertical" AllowPaging="True" AllowSorting="True">

<FooterStyle BackColor="#CCCC99" />

<RowStyle BackColor="#F7F7DE" />

<Columns>

<asp:BoundField DataField="Last_Modified_Date" HeaderText=Last Modified Date"

SortExpression="Last_Modified_Date" />

</Columns>



<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />

<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />

<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />

<AlternatingRowStyle BackColor="White" />

</asp:GridView>

It works fine but I would like is to convert the seconds that I get back into readable time..

So I thought of DateAdd(s,Last_Modified_date, January 1 1970)

Is that possible? Is there another way. Thanks
 
Old April 10th, 2008, 12:14 PM
Registered User
 
Join Date: Apr 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default


I have fixed this issue by using a DateAdd function in the query.

Select DateAdd(ss,Last_Modified_Date,01-01-1970)AS My_Modified_Date from .....

and my Gridview column becomes

<asp:BoundField DataField="My_Modified_Date" HeaderText="Modified Date"
                SortExpression="My_Modified_Date" />

Cheerio.

-Ina Gaida Binta Single Baby
 
Old April 12th, 2008, 11:42 AM
Registered User
 
Join Date: Apr 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found a huge issue - My dates were off by 70 years (depending on time zone plus or minus a few hours).

So I had to do this..

SelectCommand="
            DECLARE @MyEpochDate DATETIME
            SET @MyEpochDate='1969-12-31 7:00 PM'
            SELECT Q.StatusLookup, H.Total_Admin_Effort_in_Minutes, H.Total_Labor_Effort_in_Minutes, H.Company, H.Last_Name, H.First_Name, H.Person_ID, H.Detailed_Decription, H.Resolution, DateAdd(s,H.Submit_Date,@MyEpochDate) AS My_Submit_Date, H.Incident_Number FROM HPD_Help_Desk H, QTSLookupStatus Q WHERE H.Status = Q.Status AND (H.Last_Name = @Last_Name) AND (H.Person_ID = @Person_ID) ORDER BY Incident_Number"



-Ina Gaida Binta Single Baby





Similar Threads
Thread Thread Starter Forum Replies Last Post
date and time in EST time zone anboss XSLT 1 May 21st, 2008 01:42 PM
Converting enumerated value to readable value maigoro ASP.NET 3.5 Basics 2 April 11th, 2008 09:46 AM
Converting non 24hr time into number joehoe VB.NET 2002/2003 Basics 1 June 9th, 2005 08:54 AM
converting date to julian date ramlaks SQL Server 2000 1 August 23rd, 2004 10:28 AM
converting database driver in run time shun Pro VB Databases 0 July 16th, 2004 10:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.