Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
dear sir/ma'am,


i fetch time from table as

ds.tables("che").rows(0).item("time")

value i got as

01/01/1900 06:00:00

sir i want to check this value lie with in an interval

06:00:00 to 08:00:00
how can i do it,
help ,me regarding this
Posted

How about something simple like this:

VB
if ((ds.tables("che").rows(0).item("time") >= "01/01/1900 06:00") and (ds.tables("che").rows(0).item("time") <= "01/01/1900 08:00")) then
 
Share this answer
 
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dt_table = DateTime.Now;

            Console.WriteLine(dt_table);

            DateTime dt_compare_1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 0, 0);
            DateTime dt_compare_2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 1, 0, 0);

            if (dt_table > dt_compare_1 && dt_table < dt_compare_2)
                Console.WriteLine("Time is between 11 and 12 o'clock");
            else
                Console.WriteLine("Time is not between 11 and 12 o'clock");

            Console.ReadKey();
        }
    }
}
 
Share this answer
 
C#
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dt_table = DateTime.Now;

            Console.WriteLine(dt_table);

            DateTime dt_compare_1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 0, 0);
            DateTime dt_compare_2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 1, 0, 0);

            if (dt_table > dt_compare_1 && dt_table < dt_compare_2)
                Console.WriteLine("Time is between 11 and 12 o'clock");
            else
                Console.WriteLine("Time is not between 11 and 12 o'clock");

            Console.ReadKey();
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900