How can I convert ticks to a date format?

前端 未结 4 520
心在旅途
心在旅途 2020-11-27 20:06

I am converting a ticks value to a date like this:

Convert(datetime, (MachineGroups.TimeAdded - 599266080000000000)/864000000000);

Using th

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 20:23

        private void button1_Click(object sender, EventArgs e)
        {
            long myTicks = 633896886277130000;
            DateTime dtime = new DateTime(myTicks);
            MessageBox.Show(dtime.ToString("MMMM d, yyyy"));
        }
    

    Gives

    September 27, 2009
    

    Is that what you need?

    I don't see how that format is necessarily easy to work with in SQL queries, though.

提交回复
热议问题