locked
Sqlite datetime

    General discussion

  • i have table , name is reminder , their is lot of date time

    i want select 10 date time  and sort by ascending to  current date time . 

     

    which query i use

    public class Event : ObservableObject
        {
    
    /// <summary>
            /// Initializes a new instance of the <see cref="Event" /> class.
            /// </summary>
            public Event()
            {
                Id = Guid.NewGuid();
            }
    
            /// <summary>
            /// The id
            /// </summary>
            private Guid _id;
            /// <summary>
            /// Gets or sets the id.
            /// </summary>
            /// <value>
            /// The id.
            /// </value>
            [PrimaryKey]
            public Guid Id
            {
                get
                {
                    return _id;
                }
                set
                {
                    Set("Id", ref _id, value);
                }
            }
    
    /// <summary>
            /// The eventDateTime
            /// </summary>
            private DateTime _eventDateTime;
            /// <summary>
            /// Gets or sets the EventDateTime.
            /// </summary>
            public DateTime EventDateTime
            {
                get
                {
                    return _eventDateTime;
                }
                set
                {
                    Set("EventDateTime", ref _eventDateTime, value);
                }
            }
    
    /// <summary>
            /// The eventName
            /// </summary>
    
            private string _eventName;
            /// <summary>
            /// Gets or sets the EventName.
            /// </summary>
            [MaxLength(50)]
            public string EventName
            {
                get
                {
                    return _eventName;
                }
                set
                {
                    Set("EventName", ref _eventName, value);
                }
            }
    }

     i want countdown that date time .  can i use this code

    //Get these values however you like.
    DateTime daysLeft = DateTime.Parse("1/1/2012 12:00:01 AM");
    DateTime startDate = DateTime.Now;
    
    //Calculate countdown timer.
    TimeSpan t = daysLeft - startDate;
    string countDown = string.Format("{0} Days, {1} Hours, {2} Minutes, {3} Seconds til launch.", t.Days, t.Hours, t.Minutes, t.Seconds);

    Monday, October 06, 2014 5:49 AM

All replies

  • Hi SENTILSEBASTIAN,

    You cannot use subtraction directly on DataTime object, but datetime class provides subtract method. Try you code like this.

        DateTime daysLeft = DateTime.Parse("1/1/2012 12:00:01 AM");

                DateTime startDate = DateTime.Now;

                TimeSpan t = startDate.Subtract(daysLeft);

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 08, 2014 5:15 AM
    Moderator