i'm trying to convert the time that i get from a sql database to datetime in asp.net. the column type in the database is time(7)
, the column is named "vertrek_uur"
, i have tried this code, but it throws an applicationException
我正在尝试将我从sql数据库获取的时间转换为asp.net中的datetime。数据库中的列类型是time(7),列名为“vertrek_uur”,我试过这段代码,但它抛出了一个applicationException
vertrek_uur = Convert.ToDateTime(reader["vertrek_uur"]))
Sample Time:
Time is Stored in Databas like this 10:00:00,0000000
时间存储在像这样的10:00:00,0000000的数据库中
Goal:
I want to parse it like 10:00
我想像10点一样解析它
1 个解决方案
#1
0
i know there is lots of way to get this anyhow this is one
我知道有很多方法可以得到这个,无论如何这是一个
using System;
public class Program
{
public static void Main()
{
string a ="10:00:00,0000000";
string b = a.Substring(0,5);
Console.WriteLine(b);
}
}
Output: 10:00
#1
0
i know there is lots of way to get this anyhow this is one
我知道有很多方法可以得到这个,无论如何这是一个
using System;
public class Program
{
public static void Main()
{
string a ="10:00:00,0000000";
string b = a.Substring(0,5);
Console.WriteLine(b);
}
}
Output: 10:00