Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET和SQL Server的阿姆哈拉语日历问题_Asp.net_Sql Server_Vb.net - Fatal编程技术网

ASP.NET和SQL Server的阿姆哈拉语日历问题

ASP.NET和SQL Server的阿姆哈拉语日历问题,asp.net,sql-server,vb.net,Asp.net,Sql Server,Vb.net,我用的是阿姆哈拉语日历,有13个月。现在,如果在SQL server中使用datetime数据类型来存储此日期,则无法存储第13个月的值 有没有人遇到过类似的情况?请帮忙 这个问题对我来说有点不清楚,因为标题是ASP.NET和SQL Server的阿姆哈拉语日历问题,而您的问题是专门针对SQL Server的 通常,您应该在SQL server上将日期/时间值存储为UTC。这样,当您使用ASP.NET/C时,可以引用诸如NodeTime之类的库,并使用它来操作要引用的日历 或者,您可以创建自己的

我用的是阿姆哈拉语日历,有13个月。现在,如果在SQL server中使用datetime数据类型来存储此日期,则无法存储第13个月的值


有没有人遇到过类似的情况?请帮忙

这个问题对我来说有点不清楚,因为标题是ASP.NET和SQL Server的阿姆哈拉语日历问题,而您的问题是专门针对SQL Server的

通常,您应该在SQL server上将日期/时间值存储为UTC。这样,当您使用ASP.NET/C时,可以引用诸如NodeTime之类的库,并使用它来操作要引用的日历

或者,您可以创建自己的自定义类来实现日历。我个人认为,如果您不熟悉如何使用NodaTime,这将是最简单的方法,但我强烈建议您使用NodaTime来解决此问题。下面是实现您自己的日历的存根

    public class MyCustomCalendar : Calendar
   {

    private int _months;
    private readonly int _totalMonths = 13;

    //i.e, Amharic calendar
    public MyCustomCalendar()
    {
        _months = _totalMonths;
    }

    public override int[] Eras
    {
        get
        {
            throw new NotImplementedException();
        }
    }

    public override DateTime AddMonths(DateTime time, int months)
    {
        throw new NotImplementedException();
    }

    public override DateTime AddYears(DateTime time, int years)
    {
        throw new NotImplementedException();
    }

    public override int GetDayOfMonth(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override DayOfWeek GetDayOfWeek(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override int GetDayOfYear(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override int GetDaysInMonth(int year, int month, int era)
    {
        throw new NotImplementedException();
    }

    public override int GetDaysInYear(int year, int era)
    {
        throw new NotImplementedException();
    }

    public override int GetEra(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override int GetMonth(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override int GetMonthsInYear(int year, int era)
    {
        throw new NotImplementedException();
    }

    public override int GetYear(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override bool IsLeapDay(int year, int month, int day, int era)
    {
        throw new NotImplementedException();
    }

    public override bool IsLeapMonth(int year, int month, int era)
    {
        throw new NotImplementedException();
    }

    public override bool IsLeapYear(int year, int era)
    {
        throw new NotImplementedException();
    }

    public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
    {
        throw new NotImplementedException();
    }
}

这个问题对我来说有点不清楚,因为标题是关于ASP.NET和SQL Server的阿姆哈拉语日历问题,而你的问题是专门针对SQL Server的

通常,您应该在SQL server上将日期/时间值存储为UTC。这样,当您使用ASP.NET/C时,可以引用诸如NodeTime之类的库,并使用它来操作要引用的日历

或者,您可以创建自己的自定义类来实现日历。我个人认为,如果您不熟悉如何使用NodaTime,这将是最简单的方法,但我强烈建议您使用NodaTime来解决此问题。下面是实现您自己的日历的存根

    public class MyCustomCalendar : Calendar
   {

    private int _months;
    private readonly int _totalMonths = 13;

    //i.e, Amharic calendar
    public MyCustomCalendar()
    {
        _months = _totalMonths;
    }

    public override int[] Eras
    {
        get
        {
            throw new NotImplementedException();
        }
    }

    public override DateTime AddMonths(DateTime time, int months)
    {
        throw new NotImplementedException();
    }

    public override DateTime AddYears(DateTime time, int years)
    {
        throw new NotImplementedException();
    }

    public override int GetDayOfMonth(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override DayOfWeek GetDayOfWeek(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override int GetDayOfYear(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override int GetDaysInMonth(int year, int month, int era)
    {
        throw new NotImplementedException();
    }

    public override int GetDaysInYear(int year, int era)
    {
        throw new NotImplementedException();
    }

    public override int GetEra(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override int GetMonth(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override int GetMonthsInYear(int year, int era)
    {
        throw new NotImplementedException();
    }

    public override int GetYear(DateTime time)
    {
        throw new NotImplementedException();
    }

    public override bool IsLeapDay(int year, int month, int day, int era)
    {
        throw new NotImplementedException();
    }

    public override bool IsLeapMonth(int year, int month, int era)
    {
        throw new NotImplementedException();
    }

    public override bool IsLeapYear(int year, int era)
    {
        throw new NotImplementedException();
    }

    public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
    {
        throw new NotImplementedException();
    }
}

在这里,您可以找到c中的项目,该项目将从埃塞俄比亚日期转换为公历日期,反之亦然:

使用示例:

private EthiopicCalendar.Calendar ec = new Calendar();
var selected = this.dateTimePicker1.Value;           

// Using the ec instance of the Calendar class
textBox.Text = ec.GregorianToEthiopic(selected.Date);

// Directly using method chaining
label.Text = new EthiopicDateTime(selected.Date).ToString();

转换为公历日期后,可以将其存储在SQL Server日期列中,并根据需要进行查询。当您想显示查询结果时,只需将其转换回阿姆哈拉语日期。

在这里,您可以找到c中的project,将埃塞俄比亚日期转换为格里高利日期,反之亦然:

使用示例:

private EthiopicCalendar.Calendar ec = new Calendar();
var selected = this.dateTimePicker1.Value;           

// Using the ec instance of the Calendar class
textBox.Text = ec.GregorianToEthiopic(selected.Date);

// Directly using method chaining
label.Text = new EthiopicDateTime(selected.Date).ToString();

转换为公历日期后,可以将其存储在SQL Server日期列中,并根据需要进行查询。当您想显示查询结果时,只需将其转换回阿姆哈拉语日期。

请注意,您只能将阿姆哈拉语日历或任何其他日期(如波斯日历)存储到SQL Server中,以便将其转换为基督教日期

SQL Server仅理解DateTime类型,该类型是基督教日期

您应该使用一种方法将阿姆哈拉语日期转换为基督教日期,反之亦然。 例如:

private DateTime Amharic2Christian(string strAmharicDate)
{
    // Note: Here you have to know the algorithm of converting
    // from Amharic date to Christian date.
}


private string Christian2Amharic(DateTime dtChristianDate)
{
    // Note: Here you have to know the algorithm of converting
    // from Christian date to Amharic date.
}

因此,当您想将给定日期存储为阿姆哈拉语(例如文本框的内容)时,应使用阿姆哈拉语方法将其转换为DateTime类型,当您想将存储的日期显示为阿姆哈拉语日期时,请使用Christian2Amharic方法。

请注意,您只能将阿姆哈拉语日历或任何其他日期(如波斯日历)存储到SQL Server中,以使其可转换为基督教日期

SQL Server仅理解DateTime类型,该类型是基督教日期

您应该使用一种方法将阿姆哈拉语日期转换为基督教日期,反之亦然。 例如:

private DateTime Amharic2Christian(string strAmharicDate)
{
    // Note: Here you have to know the algorithm of converting
    // from Amharic date to Christian date.
}


private string Christian2Amharic(DateTime dtChristianDate)
{
    // Note: Here you have to know the algorithm of converting
    // from Christian date to Amharic date.
}

因此,当您想将给定日期存储为阿姆哈拉语(例如文本框的内容)到db中时,您应该使用阿姆哈拉语C2Christian方法将其转换为DateTime类型,当您想将存储的日期显示为阿姆哈拉语日期时,使用Christian2Amharic方法。

尽管您的问题非常清楚。。但我要求你们的问题更简短一些,举例说明你们的情况,并感谢你们的评论。很少有人在ASP.NET应用程序中使用阿姆哈拉语。如果有人这样工作过,他们也会遇到同样的问题。你可以把数据放在varchar列中。不要用datetime来存储这些日期。改为使用nvarchar.True,但在这种情况下,我无法对该列执行任何与日期时间相关的操作,这是不合适的。我必须在报告中使用那个栏,那个栏有按日期范围搜索的功能。尽管你们的问题很清楚。。但我要求你们的问题更简短一些,举例说明你们的情况,并感谢你们的评论。很少有人在ASP.NET应用程序中使用阿姆哈拉语。如果有人这样工作过,他们也会遇到同样的问题。你可以把数据放在varchar列中。不要用datetime来存储这些日期。改为使用nvarchar.True,但在这种情况下,我无法对该列执行任何与日期时间相关的操作,这是不合适的。我必须在报表中使用该列,它具有按日期范围搜索的功能。OP询问如何在SQL Server中存储阿姆哈拉语日期,而不是如何在SQL Server中计算阿姆哈拉语日期C@PanagiotisKanavos但若他将日期转换为公历,那个么他就可以将其存储在sql server的日期列中
“没问题吗?”莱斯米安,这很好。您对SQL server有类似的功能吗?我的意思是在SQL server中将日期从阿姆哈拉语转换为格里高利语。我也需要它,因为我使用存储过程在我的视图页面中显示结果。所以我要做的是,当用户选择阿姆哈拉语日期时,它会被转换成公历并保存在数据库中。现在,当我在查看页面上显示时,它以公历显示。应该是阿姆哈拉语。所以我在SQLServer中也看到了同样的情况。如果您有,请告诉我。@PiyushKhatri-Nah您在sql server中不需要它。只需执行存储过程以获取格里高利日期,然后在c中将其转换回阿姆哈拉语日期并将其传递给视图。在这种情况下,您将使用方法:ec.GregoriantoEthiopicDateFromStoredProcess@莱斯米安:是的。你是对的,我们可以做同样的事情。但在我的数据库中,我有大约5万条记录。我得到了它们,我在c上处理,加载页面将花费很多时间。这就是为什么我更喜欢sql server端的东西。我接受你的回答。但仍然为我寻找sql server方面的东西。非常感谢您的帮助。OP询问如何在SQL Server中存储阿姆哈拉语日期,而不是如何在SQL Server中计算阿姆哈拉语日期C@PanagiotisKanavos但如果他将日期转换为公历,那么他就可以毫无问题地将其存储在sql server日期列中?@Lesmian这很好。您对SQL server有类似的功能吗?我的意思是在SQL server中将日期从阿姆哈拉语转换为格里高利语。我也需要它,因为我使用存储过程在我的视图页面中显示结果。所以我要做的是,当用户选择阿姆哈拉语日期时,它会被转换成公历并保存在数据库中。现在,当我在查看页面上显示时,它以公历显示。应该是阿姆哈拉语。所以我在SQLServer中也看到了同样的情况。如果您有,请告诉我。@PiyushKhatri-Nah您在sql server中不需要它。只需执行存储过程以获取格里高利日期,然后在c中将其转换回阿姆哈拉语日期并将其传递给视图。在这种情况下,您将使用方法:ec.GregoriantoEthiopicDateFromStoredProcess@莱斯米安:是的。你是对的,我们可以做同样的事情。但在我的数据库中,我有大约5万条记录。我得到了它们,我在c上处理,加载页面将花费很多时间。这就是为什么我更喜欢sql server端的东西。我接受你的回答。但仍然为我寻找sql server方面的东西。非常感谢你的帮助。