Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 9th, 2008, 08:12 PM
Registered User
 
Join Date: Apr 2008
Location: Kano, Kano, Nigeria.
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
  #2 (permalink)  
Old April 10th, 2008, 12:14 PM
Registered User
 
Join Date: Apr 2008
Location: Kano, Kano, Nigeria.
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
  #3 (permalink)  
Old April 12th, 2008, 11:42 AM
Registered User
 
Join Date: Apr 2008
Location: Kano, Kano, Nigeria.
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.