SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    converting a date time value to a timestamp

    I have a web page that has a textbox for users to enter a datestring to check against a database. The database that I am running my query against has datetime values set at minutes since 12/31/1899 and that returns a timestamp. What I'd like to do in my code is to convert my textbox entry into minutes since 12/31/1899. Does anyone have an easy way to do that?

    Thank you

    Doug

  2. #2
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Assuming that users enter a valid date, try this (approximate code)
    Code Csharp:
    var date=DateTime.Parse(input.Text); //replace with whatever string provided by user
    var time=date.Substract(new DateTime(1899,12,31));
    //total minutes 
    var minutes=time.TotalMinutes;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •